Click here to Skip to main content
6,595,444 members and growing! (19,131 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » General     Intermediate License: The Code Project Open License (CPOL)

Increment Build No in VS.Net

By Ariadne

Little quick and dirty programm (60 lines), which updates the version build no each time a release is build
C#, Windows, .NET CF, .NET 1.1VS.NET2003, Dev
Posted:29 Jul 2005
Updated:28 Jan 2008
Views:31,596
Bookmarked:21 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
5 votes for this article.
Popularity: 3.18 Rating: 4.56 out of 5
1 vote, 20.0%
1

2

3

4
4 votes, 80.0%
5

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:

    copy IncBuildNo into the same directory as AssemblyInfo.cs (normally the $(ProductDir))
    in VS.Net select Project -> Properties -> Build Events
    insert in Post-build Event CommandLine:
    "$(ProjectDir)IncBuildNo" "$(ProjectDir)AssemblyInfo.cs" $(ConfigurationName)
    select in Run the Post-Build Event? When build updates the project output
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Ariadne


Member
My first approach to computers was in 1970 a IBM1160, a real desk computer, this means it was as large as a desk and had a cartreader and 32 kByte Memory! But it runs FORTRAN! Ok 'run' is a little too fast

Later I was very proud on my Comodore CBM8032 32KbRAM+32KbRom (uff!) and 2 (in words 'TWO') floppies. But it was able to run a Basic-Interpreter. (There was a young gay in USA, who invent and developed the garbage collecter for such interpreter, his name was Bill G.)

Unfortunatly this CBM8032 burned away due to some "experiements"...

Ok, later I studied physics and work now since 20 years in the cancer research in Switzerland. My own little company Ariadne-Consulting delivers the login name:

Ariadne


Occupation: Software Developer (Senior)
Company: EndoTherm GmbH
Location: Switzerland Switzerland

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
  • Pocket 1945 - A C# .NET CF Shooter
    An article on Pocket PC game development
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 8 of 8 (Total in Forum: 8) (Refresh)FirstPrevNext
GeneralMy version of that PinmemberPIEBALDconsult9:30 28 Jan '08  
GeneralRe: My version of that PinsupporterAriadne21:22 28 Jan '08  
Generalissues when implementing in c# SmartClient Project PinmemberSirGolphknut9:24 4 Apr '06  
GeneralRe: issues when implementing in c# SmartClient Project [modified] PinsupporterAriadne3:46 28 Jan '08  
General... and this is how to do it in VB.NET !!! Pinmemberdaniellus4:07 10 Nov '05  
GeneralRe: ... and this is how to do it in VB.NET !!! Pinmemberimxuf13:58 23 May '07  
GeneralIncrement build number in VS.Net PinmemberKoszyk1:00 3 Aug '05  
GeneralRe: Increment build number in VS.Net PinsupporterAriadne4:53 3 Aug '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 28 Jan 2008
Editor:
Copyright 2005 by Ariadne
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project