If I create a "Hello World" .NET Core C# Console application in Visual Studio 2017 and run
dotnet publish -c Release -r win10-x64 --self-contained
The resulting publish
folder has 215 files in it, totals 62MB and includes the whole of .NET, which the application doesn't use. For example, it has System.Security.Cryptography.OpenSsl.dll
.
This is part of the "Microsoft.NETCore.App" dependency which I seem to have no way to edit manually. How can I trim that down to what the application is actually using?
答案 0 :(得分:2)
与FDD不同,自包含部署(SCD)不依赖于目标系统上共享组件的存在。所有组件包括.NET Core库和.NET Core运行时都包含在应用程序中
(强调我的)
如果您不想将整个.NET Core运行时与应用程序一起部署,那么您应该使用Framework-dependent Deployment(FDD)而不是Self-contained Deployment(SCD)。
dotnet publish -c Release
将来,CoreRT runtime - 在编写时仍在开发中 - 旨在允许创建特定于运行时的单个预编译本机可执行文件,而不需要任何其他文件。
参考:Is there a way to make a console application run using only a single file in .NET Core?
答案 1 :(得分:1)
还有第三个选项:“ https://logging.apache.org/log4j/2.x/manual/configuration.html”
您需要使用--self-contained false
,例如:
dotnet publish <xyz.csproj> -c Release -r win-x64 --self-contained false
“发布”文件夹仍然包含一些Microsoft。*。dll。但是方式更少。就我而言,以前的发布是文件夹大小为84MB,现在只有12MB!