Global and local AssemblyInfo C# with Example



Global and local AssemblyInfo C# with Example

Having a global allows for better DRYness, you need only put values that are different into AssemblyInfo.cs for 
projects that have variance. This use assumes your product has more than one visual studio project. 
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 - one for each project 
//then the following might be put into a separate Assembly file per project, e.g. 
[assembly: AssemblyTitle("Stackoveflow.Redis")] 
You can add the GlobalAssemblyInfo.cs to the local project using the following procedure: 
1. Select Add/Existing Item... in the context menu of the project 
2. Select GlobalAssemblyInfo.cs 
3. Expand the Add-Button by clicking on that little down-arrow on the right hand 
4. Select "Add As Link" in the buttons drop down list 

0 Comment's

Comment Form

Submit Comment