There remains like this, how you can create a single file?
Answer 1, Authority 100%
You need to publish Build – & gt; Publish application in the publishing settings select Folder , then select win-x64 file and tick Produce single file .
The publication of the application with a single file by using Visual Studio
Visual Studio creates reusable publication structures, which govern the process of publication of the application.
- In the Solution Explorer, right-click the project you want to publish. Click Publish .
If you do not have a profile publications, follow the instructions to create it and select folder as the type of the target object.- Click Edit .
- In the dialog box Profile Settings , set the following parameters.
- The parameter Deployment Mode , set the value of the Independent or Dependent on platform.
- The value of the parameter Target runtime , specify the platform on which to perform the publication. (The value must be different from the Portable .)
- Click Create a separate file .
Click Save , to save the settings and return to the Publish dialog box.
- To publish an application with a single file, click Publish .
For more information, see. Article Publishing applications. NET Core using Visual Studio .
With regard to what options are Self-contained and Framework-dependent are different, I have previously told here .
If all goes well, the publication profile Properties \ PublishProfiles \ FolderProfile.pubxml will look like this
& lt;? Xml version = "1.0" encoding = "utf-8" & gt?;
& lt;! -
https://go.microsoft.com/fwlink/?LinkID=208121.
- & gt;
& Lt; Project ToolsVersion = "4.0" xmlns = "http://schemas.microsoft.com/developer/msbuild/2003" & gt;
& Lt; PropertyGroup & gt;
& Lt; Configuration & gt; Release & lt; / Configuration & gt;
& Lt; Platform & gt; Any CPU & lt; / Platform & gt;
& Lt; PublishDir & gt; bin \ Release \ Publish & lt; / PublishDir & gt;
& Lt; PublishProtocol & gt; FileSystem & lt; / PublishProtocol & gt;
& Lt; TargetFramework & gt; net5.0-windows & lt; / TargetFramework & gt;
& Lt; RuntimeIdentifier & gt; win-x64 & lt; / RuntimeIdentifier & gt;
& Lt; SelfContained & gt; false & lt; / SelfContained & gt;
& Lt; PublishSingleFile & gt; True & lt; / PublishSingleFile & gt;
& Lt; PublishReadyToRun & gt; False & lt; / PublishReadyToRun & gt;
& Lt; / PropertyGroup & gt;
& Lt; / Project & gt;
And it will be in the interface publication look like
Note for .NET 5 and more new versions
Since .NET 5 optimized application launch technology from a single file, now by default it does not include native libraries, and includes only managed.
If your assembly depends on native libraries, and you are faced with the fact that DLL files when publishing still lie separately, then to cure, in the first section & lt; PropertyGroup & GT;
. CPROJ File need to add an option:
& lt; includenativelibrariasforselfextract & gt; true & lt; / includenativelibrariesForSelfeTract & gt;