开发者

Automatically advance minor version number every build (VS 2008)

开发者 https://www.devze.com 2022-12-10 17:28 出处:网络
I use the assembly information version number - and advance it manually through the VS 2008. Is there a way to advance t开发者_运维问答he minor version number automatically each time I Build the solu

I use the assembly information version number - and advance it manually through the VS 2008.

Is there a way to advance t开发者_运维问答he minor version number automatically each time I Build the solution ?


I used this MSBuild Task to auto-increment my build numbers - requires a few manual modifications in your *.csproj or *.vbproj files, but it works quite flawlessly, and is quite flexible, too.


Visual studio have a build-in mecanism for that:

inside AssemblyInfo.cs, change the settings by this one:

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

Asterisk sign instructs Visual Studio to assign on each build a version 1.0.d.s, where d is the number of days since February 1, 2000, and s is the number of seconds since midnight/2.

EDIT:

Take a look at this webpage: http://www.codeproject.com/KB/dotnet/ManagingAssemblyVersions.aspx there is many information about: how to manage the version number.


IIRC In your solution explorer, click on "Show all files", I believe it's the third one near the top of that window.

(double)click on "My Project."

Next, double-click on "AssemblyInfo.vb"

In the code editor, scroll down until you've reached the bottom.

Comment out

Replace

<Assembly: AssemblyVersion("1.0.0.0")> 

with

<Assembly: AssemblyVersion("1.*.0")> 

Click 'Save'.

Then you're done!


One flexible option is to create a T4 template with version numbering scheme and reference a .cs file that Visual Studio generates from it. An example of such template:

<#@ template language="C#" #> // // This code was generated by a tool. Any changes made manually will be lost // the next time this code is regenerated. //

using System.Reflection;

[assembly: AssemblyVersion("1.0.1.<#= this.RevisionNumber #>")] [assembly: AssemblyFileVersion("1.0.1.<#= this.RevisionNumber #>")] <#+ int RevisionNumber = (int)(DateTime.UtcNow - new DateTime(2010,1,1)).TotalDays;

>

In this example revision number is set to the number of days since January 1st, 2010. But you can provide any custom numbering scheme, because it's plain C#.

I wrote a blog post which explains this technique in more details:

0

精彩评论

暂无评论...
验证码 换一张
取 消