.NET 5.0 bin 文件夹中的 Ref 文件夹 [英] Ref folder within .NET 5.0 bin folder

查看:54
本文介绍了.NET 5.0 bin 文件夹中的 Ref 文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译.NET 5.0 应用程序时ref 文件夹是什么?

What is the ref folder when compiling .NET 5.0 application?

我是说这个:

[project_path]inDebug
et5.0
ef

推荐答案

这些就是所谓的 参考程序集(只包含程序集公共接口的程序集),这些有助于加快构建过程,因为依赖于这个程序集的项目将能够看到没有任何理由重新编译,即使程序集的内部发生了变化,因为从外表上它仍然是一样的.

These are so called Reference Assemblies (assemblies that only contain the public interface of an assembly), these help speed up the build process, since projects that depend on this one will be able to see that there is no reason to recompile, even if the innards of the assembly have changed, because outwardly it's still the same.

这些参考组件需要从外面看起来与真实的东西一样.因此,它们具有相同的文件名、程序集名称、程序集标识和所有内容.这允许构建系统将它们用作真实事物的替代品.并且由于这些程序集没有任何实现细节,它们仅在内容的接口发生变化时才会发生变化.由于这些事实,它们不能与实际构建输出位于同一文件夹中,这就是额外的 ref 文件夹的原因.MsBuild 将自动使用这些参考程序集来加快构建过程(代价是每次编译后的代码导致新项目输出和输出目录中的一些文件时生成和比较参考程序集).

These Reference Assemblies need to look the same as the real thing from the outside. Hence, they have the same filename, assembly name, assembly identity and everything. This allows the build system to use them as a substitute for the real thing. And since these assemblies don't have any of the implementation details, they only change when the interface of the contents changes. Due to these facts, they can't live in the same folder as the actual build output, and this is the reason for the extra ref folder. MsBuild will use these reference assemblies automatically to speed up the build process (at the expense of generating and comparing the reference assembly each time the compiled code results in a new project output and a few files in the output directory).

如果您的项目没有被其他项目引用,您将不会从这些引用程序集中获得任何好处(如果您没有将它们交给 3rd 方的话).您可以通过将此属性添加到项目文件中来关闭此功能:

If your project isn't referenced by other projects, you don't get any benefits from these reference assemblies (if you don't hand them out to 3rd parties that is). And you can turn off this feature by adding this property to the project file:

<PropertyGroup>
     <!-- 
     Turns off reference assembly generation 
     See: https://docs.microsoft.com/en-us/dotnet/standard/assembly/reference-assemblies
     -->
     <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>

这些参考程序集还可用于允许人们编译项目以使用您的系统,而无需安装/重新分发在您的服务器上运行的实际编译程序集.通过这种方式,人们可以为您的应用程序开发扩展、插件或客户端,而无需让他们访问实际实现.这有助于保护您的知识产权,因为 .NET 程序集很容易反编译.

These reference assemblies can also be used to allow people to compile projects to work with your system, without having to install/redistribute the actual compiled assemblies that run on your server. This way people can develop extensions, plugins, or clients for your application without having to give them access to actual implementation. This can help protect your intellectual property, since .NET assemblies are easy to decompile.

另见:

这篇关于.NET 5.0 bin 文件夹中的 Ref 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆