Posts Tagged ‘version’

Version managing a Solution in Visual studio

October 2nd, 2011

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 through drag and drop.

As of VS2013 one can copy-paste the linked file and it is pasted as linked. This makes it very fast to insert a linked file in several projects in the same solution.

Semi hidden Add as link.

Semi hidden Add as link.

VB.Net requires a trick

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 from and Link… is where it shows up in the target project.
Presumably the easiest way to do it is to use the shared file in the root of a project and then link it through editing the project. 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)

Dynamic data

I found a trick at Stack overflow that uses T4 to enter dynamic data.

Constant reference

It is also possible to reference a constant.

<Assembly: AssemblyVersion(Common.Constants.Version)>
<Assembly: AssemblyFileVersion(Common.Constants.Version)>

and in a common file:

public const string Version = “7.1.3.*”;

I believe the value has to be a constant and not a readonly. This might (I have not bothered to check) make a difference when the common DLL is compiled but not the referencing assembly as constants are copied to the referencing assembly. A remedy might be to rebuild all.

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. Or as of later here.