使用程序集属性的最佳实践是什么?

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
  • 通过点击右侧的小向下箭头来展开添加按钮
  • 在按钮下拉列表中选择添加为链接"

这篇关于使用程序集属性的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
quot;Overflowquot; compiler error with -9223372036854775808L(编译器错误-9223372036854775808L(Q;溢出Q))
Visual Studio 2010 ReportViewer Assembly References(Visual Studio 2010 ReportViewer程序集引用)
Weird behaviour when I open a reportviewer in WPF(在WPF中打开报表查看器时出现奇怪的行为)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)