65.9K
CodeProject is changing. Read more.
Home

Versioner: An AssemblyInfo version incrementer

starIconstarIconstarIconemptyStarIconemptyStarIcon

3.00/5 (9 votes)

Jun 9, 2006

CPOL
viewsIcon

42799

downloadIcon

374

A simple C# program that will increment the AssemblyVersion attribute of an AssemblyInfo.cs file.

Introduction

AssemblyVersion attributes of AssemblyInfo.cs files look something like these:

[assembly: System.Reflection.AssemblyVersion("1.0.0.0")]
[assembly: System.Reflection.AssemblyVersion("1.0.0.*")]
[assembly: System.Reflection.AssemblyVersion("1.0.*.*")]

The asterisks in the second and third examples will cause the compiler to set those two fields, but the values used may not be very useful. If you want useful values, you need to use the first example and set them yourself, but that can be a bit tedious.

This little program of mine will find an AssemblyVersion attribute in the specified file (if one exists) and attempt to increment its fourth field by one. You will still need to set the other fields manually, but that's just the nature of the beast.

Using the code

Compile Versioner.cs with your choice of C# compiler.

To run it, use:

Versioner AssemblyInfo.cs

Such a command may be added to a Visual Studio project as a "Pre-build event", this will cause the version to be incremented automatically when the project gets built.

History

  • First uploaded - 2006/06/09.