Version managing a Solution in Visual studio

There is no problem versioning a project  - just edit the AssemblyInfo.cs file.  But how does one update all assemblies in a solution without having to update this file for every project?

Create a AssemblyInfo.shared.cs file in any project and fill it with the versioning parts.  Then link this file from all the other projects through the dropdown by the add button in the add existing file dialogue. One cannot create a file directly in the Properties folder so add it in the root of the project and then move it to the Properties folder.

Semi hidden Add as link.

Semi hidden Add as link.

VB.Net

The trick to do it is VB.Net (as of Visual studio 2012) is to update the vbproj file to something like

1
2
3
<Compile Include="..\MyOtherProject\My Project\AssemblyInfo.shared.vb">
<Link>My Project\AssemblyInfo.shared.vb</Link>
</Compile>

Above Include… is where the file is linked form and Link… is where it shows up in the target project. Presumably the easiest way to do it is to link the shared file into the root of the target project and then move it through editing the project. As with C# there is no way to directly link a file into My Project folder but one has to first link it to some other place in the target project and them move it through this hack.

(sorry for the > and < but it’s late and I really want to get the stuff into production, not update a blog)

Team city

I also cannot get it to work together with Team city.  Moving the version to a file with a different name makes Teamcity update AssemblyInfo.cs and then we get 2 references to the same [assembly: AssemblyVersion("1.0.0.0")].  Maybe this on Stackoverflow would save my day but I haven’t had the time to delve into it.
I have another solution idea and that is to set AssemblyInfo.cs as shared and then create a unique AssemblyInfo.project.cs for each project.  Have not had time for this either.

Honor those who should.

Tags: , , , ,

Leave a Reply