Shared AssemblyInfo for uniform versioning across the solution

lysergic-acid picture lysergic-acid · Jul 21, 2011 · Viewed 51.5k times · Source

I've read about this technique: Shared assembly info in VS projects - JJameson's blog

Basically it means to create a SharedAssemblyInfo.cs with versioning information about the assembly, and adding this file as Link to all projects of the solution, so the actual file resides only in 1 location on disk.

My question deals with 2 scenarios:

  1. Existing solution that doesn't use this mechanism: Is there a way to easily add the ShareAssemblyInfo to all projects? (lets say i have a solution with 50 projects).

  2. When creating a new project, by default a new AssemblyInfo.cs is created. However i'd like to link automatically to the SharedAssemblyInfo as well.

Is there any solution for this? what is the common practice?

Answer

Simon Tewsi picture Simon Tewsi · May 24, 2013

It is possible to link to a shared assembly info file in VS 2010. Ashish Jain has a good blog post about it: Sharing assembly version across projects in a solution.

After creating the shared assembly info file at the solution level, his instructions for linking to it from a project are:

  1. Right click on the project, in which you wish to add the Shared assembly file, and select Add -> Existing Item...

  2. Select the file “SharedAssemblyInfo.cs” from the solution folder.

  3. Instead of Add, click on the the arrow next to Add and click “Add as Link”

  4. Drag down the added linked file alongside AssemblyInfo.cs in the same folder.

  5. Repeat steps 1 – 4 for all projects for which you wish to add shared assembly file.

I've tried this and it works.