.Net Tips — use a shared AssemblyInfo.cs for your solution

So often when you are work­ing on a solu­tion with mul­ti­ple projects you will have to change the con­tents of the AssemblyInfo.cs file for each project so the DLLs show the cor­rect com­pa­ny, trade­mark, and most impor­tant­ly ver­sion num­bers. This is a very labo­ri­ous task and chances are you might have been won­der­ing how you can put the com­mon set­tings in one file whilst leav­ing you free to use the AssemblyInfo.cs file in the project for project-spe­cif­ic set­tings.

Well, the solu­tion is sim­ple real­ly, you can cre­ate a file, say SharedAssemblyInfo.cs, at the solution’s root direc­to­ry and put all the com­mon set­tings there. Then, every time you want to make use of the com­mon set­tings, just right-click on your project and Add an Exit­ing Item…, browse to the SharedAssemblyInfo.cs, and make sure you choose to Add As Link.

image

Once you’re done, you will see the SharedAssemblyInfo.cs in your project, along with a short­cut label:

image

Now you can safe­ly remove all the com­mon set­tings from the project’s AssemblyInfo.cs!