Tuesday, November 25, 2014

How to have one version per project

I had an experience before where I need to see the version numbers of the application and DLLs which I built. However, it would entail that I would have to open every project and modify the version numbers. It was so tiring and I got lazy doing this.

However, I found out that you can just have one assembly info and just share it with the rest of the projects inside the solution, and this is possible through the use of Link Files. Having this would reduce the time I would do to open all the assembly info files and updating every single file per project.

It is easy to do. For example you have this solution.
Below are the steps to do this:
1. Create a new folder in the solution and name it Shared Items.  Add new class and name it "SharedAssemblyInfo.cs". Then copy the contents from one of the assembly files and paste it in the "SharedAssemblyInfo.cs"

2. In the SharedAssemblyInfo.cs remove everything except the following:

  • Assembly Company
  • Assembly Copyright
  • ComVisible
  • AssemblyVersion
  • AssemblyFileVersion
Do the opposite in the other assembly files
3. Select one project (for example "Framework"), right-click then select "Add > Existing Item"
4. Point to the SharedAssemblyInfo.cs, then click the drop-down box beside the "Add" and select "Add as link". 
Then there you have it! You have a shared assembly for one project. Don't forget to move the linked file to the Properties folder. 

Do it for the rest of the projects and you can synchronize the file version across all projects.

I hope this helps! Happy coding!!!

No comments:

Post a Comment