Click here to Skip to main content
15,867,488 members
Articles / Programming Languages / C#
Article

Version Control Tool

Rate me:
Please Sign up or sign in to vote.
3.22/5 (5 votes)
2 Jun 20054 min read 57.6K   841   34   7
This tool is used to modify version information of .NET assemblies. This tool allows you to auto increment or to manually choose Assembly Version, and to increment version information of all assembly files under a selected folder.

Introduction

This tool is used to modify version information of .NET assemblies. This tool allows you to auto increment or to manually choose Assembly Version, and to increment version information of all assembly files under a selected folder.

History

Every time you rebuild your project, Visual studio tends to generate a new version of the assembly. It does this because of the following line in the AssemblyInfo file in the project. According to Jeffrey Richter, the auto increment feature of assembly version is a bug; the original intent was to increment the version of a file, not the assembly.

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

The assembly version number is part of an assembly’s identity and plays a key part in binding to the assembly and in version policy. The default version policy for the runtime is that applications run only with the versions they were built and tested with, unless overridden by explicit version policy in configuration files (the application configuration file, the publisher policy file, and the computer's administrator configuration file).

The version number has four parts and we can specify all the values or can accept the default build and revision number by using a wild character (*) to automatically generate the Build and Version number where Build Number is set to the number of days since a random, designed start date and Version Number is set to the number of seconds since midnight.

<Major Version>.<Minor Version>.<Build Number>.<Revision>

You can either use auto-increment version number or opt to manually control version number as part of the build process.

Auto IncrementManually Control or Static Version
Advantages
  • Build and Revision numbers are handled automatically by VS.NET.
  • You guarantee never to have different builds of an assembly with the same version number.
  • You have complete control over the exact version number.
  • Assembly build number can be synchronized with the system build number.
Disadvantages
  • Build and Revision numbers are not increased by 1 but are based on the time an assembly is built.
  • A new version of an assembly is generated each time it is built regardless of whether any changes have been made to the assembly.
  • Problematic when you need to support your system in the production environment as the internal assembly build number does not match your system build number.
  • Version number must be manually updated by the build coordinator or by the build support.
  • If the version is not incremented with every build, you may end up with multiple builds of the same assembly with the same strong name which is undesirable and can be problematic for assemblies that are installed in the GAC (Global Assembly Cache).

In the AssemblyInfo file for each project, you have the opportunity to set the version number of the assembly. However, in a production environment or to match specific requirements of the development team, you may want to have a unique assembly version for all the assemblies under one application or under one solution.

When the number of projects grows, they will most likely be split into multiple solutions with some of the projects contained in several solutions. So, if you have two applications App-1 and App-2, and both of them use common assemblies C, D and E, then it is nice to have a unique version for all the class library source code that is used to compile solutions App-1 and App-2.

Tool Overview

Main Screen

Image 1

The tool has a configuration file which has got two settings:

  • Revision: Current revision version which will get updated with the new version when a new version change occurs.
  • MajorMinorBuild: Current Major-Minor-Build version separated by dot (.) which will get updated with the new value when manual increment of version occurs.

VersionControl.exe.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="CommonConfiguration" 
      type="System.Configuration.NameValueSectionHandler, 
            system, Version=1.0.3300.0, Culture=neutral, 
            PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <CommonConfiguration>
         <Revision Value="7"/>
         <MajorMinorBuild Value="3.2.6"/>
  </CommonConfiguration>
</configuration>

Steps to follow to use the tool:

  • Choose a folder which has the AssemblyInfo files.

    Image 2

  • Choose either automatic Increment (default) or Manual Increment.
    1. Automatic Increment: Revision version will be incremented by 1.
    2. Manual Increment: need to choose Major, Minor, Build and Revision version from the dropdown.
  • Click on Change Version which increments/changes the version information of all the AssemblyInfo files under the selected folder and the result is shown in the datagrid.

How it works

  • Reads the Revision Version from the Config file and the same is shown in the screen.
  • If Automatic Increment:
    1. Reads the MajorMinorBuild version from the Config file.
    2. Increments the Revision version by 1.
  • If Manual Increment:
    1. Reads Major, Minor, Build and Revision version from the dropdown.
  • Concatenates MajorMinorBuild version and Revision version by dot(.).
  • Reads all the AssemblyInfo files (both .cs and .vb).
  • Searches AssemblyVersion attribute and replaces the old version with the new value in the AssemblyInfo files.
  • Updates the Version tag with the new value in the VersionControl.exe.config file.
  • Updates the MajorMinorBuild version tag with the new value in the VersionControl.exe.config file if Manual Increment is selected.
  • Attaches the result to the datagrid.

Screen shows

  • Config file version (from the configuration file).
  • New Version of the Assembly Info files.
  • Total number of AssemblyInfo files updated.
  • Grid shows: File path and the old version of the configuration files.

Main Screen – With Version Incremented

Image 3

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
I am working for Wipro Technologies. Bangalore. India.

Comments and Discussions

 
GeneralSuggestion Pin
Naya20052-Jun-05 1:28
Naya20052-Jun-05 1:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.