如何减少 C# 程序的 .exe 大小

发布于 2025-01-13 12:33:18 字数 162 浏览 3 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别挽留 2025-01-20 12:33:18

将配置设置为 Release 而不是 Debug

当用户安装了适当的 .net 运行时 时,您可以禁用Self Contained。这样可以节省很多空间。

如果您的exe包含视频等资源,它可能无法缩小。

Self Contained也有很多好处,省去了很多麻烦,可以查看官方文档了解详细信息。

Set the configuration to Release instead of Debug.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文