全域性和本地 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. 在按鈕下拉選單中選擇新增為連結