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

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

问题描述

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

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

我的意思是这个:

[project_path]\bin\Debug\net5.0\ref\

推荐答案

这些就是所谓的参考程序集(仅包含程序集公共接口的程序集),它们有助于加快构建过程,因为依赖该程序集的项目将能够看到没有理由即使该组件的内部发生了变化也可以重新编译,因为从外观上看,它仍然是相同的.

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).

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

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:

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

这些参考程序集还可用于允许人们编译项目以与您的系统一起使用,而不必安装/重新分发在服务器上运行的实际已编译程序集.这样,人们就可以为您的应用程序开发扩展,插件或客户端,而不必让他们访问实际的实现.由于.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天全站免登陆