Question

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?

Was it helpful?

Solution

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 AssemblyFileVersion attribute from the AssemblyInfo file in your project.

OTHER TIPS

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.

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.

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

Just a comment on this, the autogenerated version number cycles. So if you're looking to be able to version such that a build yesterday has a version 1.2.3.X where X < X a build today then this isn't the way to go.

To achieve this use

[assembly : AssemblyVersion("1.2.*")]

This will get you version 1.2.X.Y where the combination of X.Y is bigger today than it is yesterday. I'm guessing X.Y are a function of date and time respectively

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

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top