问题描述
我有一个包含多个项目的解决方案.我正在尝试通过链接一个解决方案范围的程序集信息文件来优化 AssemblyInfo.cs 文件.这样做的最佳做法是什么?哪些属性应该在解决方案范围的文件中,哪些是项目/程序集特定的?
I have a solution with multiple project. I am trying to optimize AssemblyInfo.cs files by linking one solution wide assembly info file. What are the best practices for doing this? Which attributes should be in solution wide file and which are project/assembly specific?
如果您有兴趣,有一个后续问题 AssemblyVersion、AssemblyFileVersion 和 AssemblyInformationalVersion 有什么区别?
推荐答案
我们正在使用一个名为 GlobalAssemblyInfo.cs 的全局文件和一个名为 AssemblyInfo.cs 的本地文件.全局文件包含以下属性:
We're using a global file called GlobalAssemblyInfo.cs and a local one called AssemblyInfo.cs. The global file contains the following attributes:
[assembly: AssemblyProduct("Your Product Name")]
[assembly: AssemblyCompany("Your Company")]
[assembly: AssemblyCopyright("Copyright 2008 ...")]
[assembly: AssemblyTrademark("Your Trademark - if applicable")]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif
[assembly: AssemblyVersion("This is set by build process")]
[assembly: AssemblyFileVersion("This is set by build process")]
本地 AssemblyInfo.cs 包含以下属性:
The local AssemblyInfo.cs contains the following attributes:
[assembly: AssemblyTitle("Your assembly title")]
[assembly: AssemblyDescription("Your assembly description")]
[assembly: AssemblyCulture("The culture - if not neutral")]
[assembly: ComVisible(true/false)]
// unique id per assembly
[assembly: Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]
您可以使用以下过程添加 GlobalAssemblyInfo.cs:
You can add the GlobalAssemblyInfo.cs using the following procedure:
- 在项目的上下文菜单中选择Add/Existing Item...
- 选择 GlobalAssemblyInfo.cs
- 通过点击右侧的小向下箭头来展开添加按钮
- 在按钮下拉列表中选择添加为链接"
这篇关于使用程序集属性的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!