将.netcore5.0发布到单个exe文件中
c#
有谁能够帮助我。我正在尝试将我的 .net 核心控制台应用程序发布到单个文件中。
我正在使用这个命令:
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true
我期待它会创建一个文件。但仍然有dll文件:
clrcompression.dll
clrjit.dll
coreclr.dll
mscordaccore.dll
我该如何解决?我已经搜索过了,但结果是一样的
回答
要捆绑本机库,您需要指定IncludeNativeLibrariesForSelfExtract标志。
所以尝试运行这个 dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true /p:IncludeNativeLibrariesForSelfExtract=true
请参阅https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file#other-conspections