In a project created by Visual Studio, a file called "AssemblyInfo.cs", which describes the assembly generated by the project, will be also automatically created. And it's very common that there is more than one project in a solution. Therefore, there will be many "AssemblyInfo.cs" existing in a solution. However, the contents of these "AssemblyInfo.cs" are more or less the same. It's a type of duplication for sure. We'd better extract all the duplicated code into a global file shared by all the projects.
The image describes the scenario: in a solution, there is a global file called "GlobalAssemblyInfo.cs" which describes assemblies generated by all the projects, and every project holds a reference to the global file.
Steps:
- Create a file called "GlobalAssemblyInfo.cs";
- Add the file to the solution as a solution item;
- Open the global file, Write appropriate codes in it. Sample:
1using System;
2using System.Reflection;
3using System.Runtime.InteropServices;
4
5[assembly : ComVisible( false )]
6[assembly : CLSCompliant( true )]
7[assembly : AssemblyProduct( "
. " )]
8[assembly : AssemblyCompany( " Company name " )]
9[assembly : AssemblyVersion( " 1.0.0.0 " )]
10#if DEBUG
11[assembly : AssemblyConfiguration( " Debug " )]
12#else
13[assembly : AssemblyConfiguration( " Release " )]
14#endif
15[assembly : AssemblyCopyright( "" )]
16[assembly : AssemblyTrademark( "" )]
17[assembly : AssemblyCulture( "" )]
- Open a project file(.csproj, etc.) in a text editor, append the following section to the <Files>/<Include> element.
1
< File
2RelPath = "GlobalAssemblyInfo.cs"
3Link = "..\Common\GlobalAssemblyInfo.cs"
4SubType = "Code"
5BuildAction = "Compile"
6/>