Fer*_*xxo 14 roslyn .net-core .net-core-publishsinglefile asp.net-core-5.0
Haiya! I'm having an issue regarding trying to compile my .NET 5 application to a single file executable while debugging through Visual Studio.
My CSProject is bellow.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net50</TargetFramework>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
I have my runtime identifier set to winx64 and publish single file set to true, yet when building I'm left with a bunch of DLLs that my application uses building along-side it (a total of 272 in total). I was wondering - how would I package these DLLs into this application? I had thought that publishing it as a single file executable would do that already-
Dan*_*Dan 25
对于 .Net 5,要在发布项目时获得单个可运行的可执行文件,重要的属性是:
您需要将它们自己包含在项目文件中,或者在命令行中指定它们。
项目文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<!--<OutputType>WinExe</OutputType>--><!--Use this for WPF or Windows Forms apps-->
<TargetFramework>net5.0</TargetFramework>
<!--<TargetFramework>net5.0-windows</TargetFramework>--><!--Use this for WPF or Windows Forms apps-->
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<RuntimeIdentifier>win-x64</RuntimeIdentifier><!--Specify the appropriate runtime here-->
</PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
命令行界面:
dotnet publish -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true
Run Code Online (Sandbox Code Playgroud)
根据您的需求,还有其他值得考虑的属性,例如:
请参阅此处的文档页面:
https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file https://github.com/dotnet/designs/blob/main/accepted/2020/single-file/design.md
| 归档时间: |
|
| 查看次数: |
8918 次 |
| 最近记录: |