views:

1611

answers:

7

I have a VS2008 project written in c# with a number of assemblies. I'd like to have a simple way of managing the version numbers between all of the different assemblies and a way to automatically increment the build number and have that saved into the version number of each assembly.

I'm guessing that this is a problem with most projects so presumably it has been solved before?

Any suggestions for how I can simplify management of my project's version resources?

A: 

You can write a custom MSBuild task to do this. Have a look at this approach

Conrad
+3  A: 

Put a file into the solution, call this "SolutionInfo.cs" (I'm assuming C#, would also work in VB). In this put all the properties you have in common. Start with AssemblyVersionAttribute.

Then in each project link to this by selecting add existing item to each project, but rather than clicking add, use the drop down to add as link.

Richard
+10  A: 

I use a .cs file on solution level that is linked by all projects in the solution which contains the following lines:

using System.Reflection;
[assembly : AssemblyVersion("1.2.3.*")]

And be sure to remove the AssemblyVersion attribute from the AssemblyInfo file in your project.

Gerrie Schenck
It doesn't look like working on VB or is it because of Express edition for VS.NET? Looks like a great trick.
dr. evil
You need to add a using also. I'll adit my answer.
Gerrie Schenck
You mean removing the "AssemblyFileVersion" attribute, right?
Alexander
A: 

You can use asterisks in your AssemblyInfo.cs:

// Version information
[assembly: AssemblyVersion( "1.0.*" )]

It will increase your versionnumbers automatically. For sharing one number between all assemblies ... I am not sure, but maybe you use the mentioned attribute in a shared file.

tanascius
+3  A: 

We have a single AssemblyInfoGlobal.cs file at solution level, like the other answers. Then we have as part of our build script a little application that takes the CCNetLabel that CruiseControl.net defines (and using the defaultLabeller to generate the labels) and checkout the global file, modify the version number, and then check the global file back in.

Some of our projects have multiple solutions, so the global file sits above the solution level in the directory structure, high enough so that everything that needs it is below it.

We also then update the deployment projects version numbers - the number for these is found within the VDProj file, but I'm not sure you will find these in the express versions - I think that's a full Professional upwards feature. And some projects have a dozen deployment projects, but no easy way to externalise the version numberf from the VDPROJ file itself. (or is there?)

Then the build happens which means that all the outputs from the build have exactly the same version number, at any time we can get the version from the MSI or assembly and we know exactly what source was used to build that output.

Alan Mullett
A: 

I've used the svnversion MSBuild community tasks to do something like this, I followed the instructions here Although the way I do it doesn't span multiple assemblies.

Ian Hopkinson