c# - 为什么 .NET Core 应用程序总是很重?

标签 c# .net-core

关闭。这个问题是opinion-based .它目前不接受答案。












想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题.

去年关闭。




Improve this question




我想知道为什么 .NET Core 应用程序总是很重?

因为当我创建一个基本的 hello world 应用程序并发布它时。无论是在一个还是多个文件中。该程序至少有 20 MB,非常庞大。事实上,依赖项(.dll)非常多。例如,“hello world”仅请求调用系统库(使用 System;)。但是生成了许多库,因此应用程序是自治的。

实际上我正在尝试创建一个 tcp 服务器/客户端连接,但是客户端太重了(至少 20 个月...)

最佳答案

您可能正在以自包含模式构建此应用程序。这意味着整个 .NET Core 运行时都包含在您的构建输出中,这将为您的构建文件添加固定的数据大小。
如果不想包含 .NET Core 运行时,则必须将应用程序构建为依赖于运行时。请记住,您只能在已预安装 .NET Core 运行时的环境中运行此应用程序。

For reference :

Publishing your app as self-contained produces an application that includes the .NET Core runtime and libraries, and your application and its dependencies. Users of the application can run it on a machine that doesn't have the .NET Core runtime installed.

Publishing your app as runtime-dependent (previously known as framework-dependent) produces an application that includes only your application itself and its dependencies. Users of the application have to separately install the .NET Core runtime.

关于c# - 为什么 .NET Core 应用程序总是很重?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62260182/

相关文章:

c# - LINQ 与嵌套循环

c# - WPF 工具包 PropertyGrid ExpandableObject 属性未正确显示嵌套类

c# - 找不到任何已安装的.NET Core SDK

c# - 如何在 .NET Core 2.1 中使用 String.Create 的示例

c# - 如何使用 System.Text.Json API 将流反序列化为对象

c# - 不用gmail发送邮件

c# - 使用 AssemblyBuilder 构建资源程序集

c# - 使用无效标记反序列化 Json

azure - 使用 .NET Core(API 和 HTTP)创建 Azure AD 应用程序和服务主体

com - 如何增加 ASP.NET Core 二进制文件(32 位)的堆栈大小?