你需要从一个C#构建中分发哪些文件?

huangapple go评论71阅读模式
英文:

Which files do I need to distribute from a C# build?

问题

当我在Windows上使用.NET 6.0构建名为`MyApplication`的C#应用程序项目时,我会得到以下文件:

**MyApplication.dll** 包含应用程序的IL代码。我肯定需要这个。

**MyApplication.exe** 是启动应用程序的存根加载器。我需要这个。

**MyApplication.pdb** 包含调试信息。我不需要分发这个。

但其他文件呢?它们似乎包含一些依赖信息。但这只是对编译器需要吗,还是后来在运行时需要?(我的应用程序由数十个dll组成)。
英文:

When I build a C# application project named MyApplication with .NET 6.0 on Windows, I get the following files:

MyApplication.dll
MyApplication.exe
MyApplication.deps.json
MyApplication.dll.config
MyApplication.pdb
MyApplication.runtimeconfig.json
MyApplication.xml

Which of these files do I need to distribute?

MyApplication.dll contains the IL code of the application. I certainly need this one.

MyApplication.exe is the stub loader that starts the application. I do need this.

MyApplication.pdb contains the debug info. I don't need to distribute this.

But what about the others? They seem to contain some dependency information. But is that only required for the compiler, or is it required later at runtime? (My application consists of dozens of dll's).

答案1

得分: 1

runtime配置文件规范中的说明:

> * MyApp.dll - MyApp的托管程序集,包括符合ECMA标准的入口点标记。
> * MyApp.exe - corehost.exe可执行文件的副本。
> * MyApp.runtimeconfig.json - 包含运行时配置设置的可选配置文件。
> * MyApp.deps.json - 依赖项列表,以及编译上下文数据和编译依赖项。不是技术上必需的,但在使用服务或包缓存/共享包安装功能时需要。

因此,虽然JSON文件不是严格必需的,但我可能建议包括它们。

MyApplication.xml是一个可选的文档文件,包含了有关您的DLL的注释。如果您正在分发一个应用程序而不是一个库,可能不需要这个文件,并且在项目属性中应该有一个选项来关闭生成此文件的功能。

您还应该查看有关部署您的应用程序的文档。我特别建议查看关于自包含单文件发布的部分。

英文:

From the spec of runtime configuration files

> * MyApp.dll - The managed assembly for MyApp, including an ECMA-compliant entry point token.
> * MyApp.exe - A copy of the corehost.exe executable.
> * MyApp.runtimeconfig.json - An optional configuration file containing runtime configuration settings.
> * MyApp.deps.json - A list of dependencies, as well as compilation context data and compilation dependencies. Not technically required, but required to use the servicing or package cache/shared package install features.

So while the json files are not strictly required, I would probably recommend including them.

The MyApplication.xml is an optional documentation file that contains comments for your dll. This is probably not needed if you are distributing an application and not a library, and there should be an option to turn of the generation of this file in your project properties.

You should also check the documentation for Deploying your application. I would especially consider the parts about self contained and single file publishing.

huangapple
  • 本文由 发表于 2023年1月9日 17:39:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75055402.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定