What are the best practices for using Assembly Attributes?(使用程序集属性的最佳实践是什么?)
问题描述
我有一个包含多个项目的解决方案.我正在尝试通过链接一个解决方案范围的程序集信息文件来优化 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
- 通过点击右侧的小向下箭头来展开添加按钮
- 在按钮下拉列表中选择添加为链接"
这篇关于使用程序集属性的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用程序集属性的最佳实践是什么?


基础教程推荐
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01