如何减少 C# 程序的 .exe 大小
我正在尝试在 C# 中使单个文件可执行。该程序没有很多代码,但即使我使用 PublishTrimmed,输出也约为 50mb。有什么办法可以减小它的大小吗?谢谢。
配置:调试|任何CPU 目标框架:net core 3.1(windows) 目标运行时:win x-64 部署模式:单文件/自包含
I am trying to make a single file executable in C#. The program does not have alot of code, yet the output is around 50mb even when I am using PublishTrimmed. Is there a way I can decrease the size of this? Thanks.
Configuration: Debug | Any CPU
Target Framework: net core 3.1 (windows)
Target Runtime: win x-64
Deployment Mode: Single File / Self Contained
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将配置设置为
Release
而不是Debug
。当用户安装了适当的
.net 运行时
时,您可以禁用Self Contained
。这样可以节省很多空间。如果您的
exe
包含视频等资源,它可能无法缩小。Self Contained
也有很多好处,省去了很多麻烦,可以查看官方文档了解详细信息。Set the configuration to
Release
instead ofDebug
.You can disable
Self Contained
when the user has the appropriate.net runtime
installed. This can save a lot of space.If your
exe
contains resources such as videos, it may not be able to shrink.Self Contained
also has many benefits and saves a lot of trouble, you can check the official documentation for details.