![](/img/trans.png)
[英]Copy file (geckodriver.exe) to publish folder when publishing ASP.NET Core MVC 2.1 project
[英]Publishing .net core 5.0 into single exe file
有谁能够帮我。 我正在尝试将我的 .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-considerations
要将 dotnet 运行时 dll 包含到您的可执行文件中,您还需要使用--self-contained
标志。 所以你可以运行dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true --self-contained true
。
请参阅https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file
我也遇到了同样的问题,但我通过浏览dotnet publish
帮助菜单找到了答案。 使用以下命令dotnet publish -r win-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
这会将 .dll 嵌入到二进制文件中,因此在发布文件夹中将仅保留一个 .pdb 文件,在此期间不需要运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.