Skip to main content
Email Password   helpLost your password?

Introduction

In VS 6 we had an autoincrement of the build no, if we build a new *.exe file. In VS.NET I missed this feature. Here I submit a quick and dirty program (60 lines), which updates the version line in AssamblyInfo.cs each time a Release version is build.

Basics

Beau Scinner has written a lot about the basics, but it works only in VS 6. In VS.NET is AssemblyInfo.cs file, which contains the information of the Application.ProductVersion in form of one line:
// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.0.13")]
IncBuildNo reads this file, increments the last number by 1 and writes it back.

Calling IncBuildNo

IncBuildNo 1st arg is the path and filename to AssemblyInfo.cs.
Optional it reads a 2nd arg Release. If the 2nd arg is given, but if arg!="Release" IncBuildNo returns without any action. I add this option, that IncBuildNo is able to select the VS.Net enviroment Release/Debug.
If you omit this 2nd arg or the 2nd arg is Release IncBuildNo increments the last number of the version string (otherwise it skips incrementation).

In the new version I add some error-output to the Application Event Log.

Installation

If you download the project above, you have a complet installed example.

In your own projects take the follwing steps:

Now each time you build a new release the last number of the version is incremented.

1st Note: After a successfull build of a release AssemblyInfo.cs shows the version of the release +1.

2nd Note: If you use a installation-project when you build your application, you can insert a line in the postbuild event property in the project properties of this installation project. I use eg.

"$(ProjectDir)IncBuildNo" "$(ProjectDir)..\AssemblyInfo.cs" $(ConfigurationName)

Attention: In this case the $(ProjectDir) points to the install project, not to the application project. This is the reason for the ..\ phrase in the above line. But then the increment happend only, if the building process is running. I.e. you can build a Release-Version without increment the build no.

I hope, this helps you.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralMy version of that Pin
PIEBALDconsult
9:30 28 Jan '08  
GeneralRe: My version of that Pin
Ariadne
21:22 28 Jan '08  
Generalissues when implementing in c# SmartClient Project Pin
SirGolphknut
9:24 4 Apr '06  
GeneralRe: issues when implementing in c# SmartClient Project [modified] Pin
Ariadne
3:46 28 Jan '08  
General... and this is how to do it in VB.NET !!! Pin
daniellus
4:07 10 Nov '05  
GeneralRe: ... and this is how to do it in VB.NET !!! Pin
imxuf
13:58 23 May '07  
GeneralIncrement build number in VS.Net Pin
Koszyk
1:00 3 Aug '05  
GeneralRe: Increment build number in VS.Net Pin
Ariadne
4:53 3 Aug '05  


Last Updated 28 Jan 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009