全局和本地 AssemblyInfo

拥有全局允许更好的 DRYness,你只需要将具有不同值的值放入 AssemblyInfo.cs 中以用于具有差异的项目。此用途假定你的产品具有多个 Visual Studio 项目。

GlobalAssemblyInfo.cs

using System.Reflection;
using System.Runtime.InteropServices;
//using Stackoverflow domain as a made up example    

// It is common, and mostly good, to use one GlobalAssemblyInfo.cs that is added 
// as a link to many projects of the same product, details below
// Change these attribute values in local assembly info to modify the information.
[assembly: AssemblyProduct("Stackoverflow Q&A")]
[assembly: AssemblyCompany("Stackoverflow")]
[assembly: AssemblyCopyright("Copyright © Stackoverflow 2016")]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4e4f2d33-aaab-48ea-a63d-1f0a8e3c935f")]
[assembly: ComVisible(false)] //not going to expose ;)

// Version information for an assembly consists of the following four values:
// roughly translated from I reckon it is for SO, note that they most likely 
// dynamically generate this file
//      Major Version  - Year 6 being 2016
//      Minor Version  - The month
//      Day Number     - Day of month
//      Revision       - Build number
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below: [assembly: AssemblyVersion("year.month.day.*")]
[assembly: AssemblyVersion("2016.7.00.00")] 
[assembly: AssemblyFileVersion("2016.7.27.3839")]

AssemblyInfo.cs - 每个项目一个

//then the following might be put into a separate Assembly file per project, e.g.
[assembly: AssemblyTitle("Stackoveflow.Redis")]

你可以使用以下过程将 GlobalAssemblyInfo.cs 添加到本地项目 :

  1. 在项目的上下文菜单中选择 Add / Existing Item ….
  2. 选择 GlobalAssemblyInfo.cs
  3. 单击右侧的小向下箭头展开添加按钮
  4. 在按钮下拉列表中选择添加为链接