More Group Sites
School Rankings
Jobless Net
Better Home
Enviro++


Help | Subscribe/Unsubscribe | Rules | Other Group Sites: Better Education | Better Education Forum
Welcome Guest Search | Active Topics | Members | Log In | Register

How can I auto increment the C# assembly version? Options · View
hong
Posted: Monday, May 09, 2011 9:50:55 PM

Rank: Administration
Groups: Administration

Joined: 11/23/2008
Posts: 335
Points: 711
Location: Australia
Just open AssemblyInfo.cs file in your project, set your assembly version to major.minor.* (for example: 0.4.*). When you build your project the version will be generated automatically.

Note that in AssemblyInfo.cs as shown below, you can specify all the version values or you can default the Build and Revision Numbers by using the '*'.
Code:
// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version
//      Build Number
//      Revision
//
[assembly: AssemblyVersion("0.4.*")]


The build and revision numbers are generated based on the date using the unix epoch. The build is based on the current day, and the revision is based on the number of seconds since midnight, ie. build.revision = date.time.

You have to remove the AssemblyFileVersion. Removing AssemblyFileVersion allows the version to update.

To get the version information, you can use the Application or Environment objects in Windows Forms, for example, Environment .Version.ToString().
Code:
Environment.Version.Major;
Environment.Version.Minor;
Environment.Version.Build;
Environment.Version.Revision;
Environment.Version.MajorRevision;
Environment.Version.MinorRevision;


However, in .net, it's expected that the major version starts from 1. If the major version is set to 0, Environment.Version.Major may become 2. In this instance, you can get version information using reflection on your assembly:
Code:

System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
System.Reflection.AssemblyName myAssemblyName = myAssembly.GetName();
Version ver = myAssemblyName.Version;


Related:
How to Remove Previous Version with Windows Installer
Sponsor
Posted: Monday, May 09, 2011 9:50:55 PM
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

ASPNET Theme created by Boskone (Dan Ferguson)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.217 seconds.