Home » Programming » Set the same assembly info, once, for multiple projects in the same solution

Set the same assembly info, once, for multiple projects in the same solution

Let’s suppose we have a solution (LibrarySolution), with 2 projects:

  1. a class library for the data (DataLayer project)
  2. a WPF user interface (LibraryUI project).

Each of these projects have their own assembly info, as shown below.

Each project has its own AssemblyInfo

The issues is that each time the version number is changed in one of the projects, you have to manually change it in the other project as well. This maybe wouldn’t be such a burdain if there were only 2 projects and the same person would be responsible to update them. But when you have multiple projects or multiple people updating the versions and they are not aware of the necesairy update, then you have a big problem.

The solution would be to create a class library to keep the common version info – and this way you have to change it only once and it will change in all the places that it is referenced.

Create a new class library to store the common AssemblyInfo data

This new project (AssemblyData) doesn’t need any classes, just place the common assemblyInfo data that you want to use in multiple .net projects from this solution.

Set the common AssemblyInfo data

Now, in every project that you want to use this version you have to:

  1. Add a reference to the AssemblyData project
  2. Add an “existing file” link to the AssemblyInfo.cs file from the AssemblyData project
  3. Remove the common assembly data from the project, and specify it only in the AssemblyData project

Step 1 – Add a reference to the AssemblyData project

Step 2 – Add an “existing file” link to the AssemblyInfo.cs file from the AssemblyData project

Both projects have references to the AssemblyData project and link to AssemblyInfo.cs

Step 3 – Remove the common assembly data from the project, and specify it only in the AssemblyData project

Now if we build the solution and change the version number in the AssemblyInfo.cs file from AssemblyData project, we will have the same version for both DataLayer and LibraryUI projects

Same version number for all the projects

Posted in Programming and tagged as ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.