Introduction

Not satisfied with the versioning capabilities of Visual Studio? Try this tool.

Using the code

This code does nothing more than read the AssemblyInfo file of your project and updates the version information based upon your selected method. Basically was designed to be run either as an external tool or from build events.

In all examples below, quotes are very important

Arguments:

-p = project name
-f = project folder
-s = version schema

From command line:

updatever -p="MyProject.vbproj" -f="C:\Documents and Settings\userid\My Documents\Visual Studio 2008\Projects\ProjectFolder\MyProject" -s="schemaname"

From Visual Studio as an External Tool: 

Start Visual Studio IDE
Go to Tools
Select External Tools...
Click Add
Title = Update Version
Command = C:\SomeFolder\UpdateVer.exe
Arguments = -p="$(ProjectFileName)" -f="$(ProjectDir)" -s="schemaname"
Check Use output window
Click Ok

As Pre Build Event:

Start Visual Studio IDE
Go To Project properties
Click Compile (VB) or Build Events (C#)
Click Build Events (VB)
In Pre Build event command line box, enter
if not $(ConfigurationName) == DEBUG (
"C:\SomeFolder\UpdateVer.exe" -p="$(ProjectFileName)" -f="$(ProjectDir)"" -s="schemaname"
)

Methods:

Methods do the actual version revision. Descriptions of the provided methods are below:

  • ignore - ignores the value and returns current version number
  • increment - increments the current version number
  • incrementeachday - will only increment if the date is greater then the previous version update stored as a comment in the AssemblyInfo file
  • incrementreseteachday - will continue to increment the version number, but will reset that value to 0 if the date is greater then the previous version update
  • random - selects a random version number
  • dayvalue - number of days since 01/01/1900
  • dayvaluefrom - number of days since value specified as a parameter in the level element for the method
  • secondvalue - number of seconds since 01/01/1900
  • secondvaluefrom - number of seconds since value specified as a parameter in the level element for the method
  • fixed - sets to the value specified as a parameter in the level element for the method
  • year - current date year
  • month - current date month
  • day - current date day

Version number methods are hard-coded in the UpdateMethods.vb file. I have provided the source code, so if you have some others you would like to use, code them and recompile. You will also need to add a call to the method in the ProcessMethod method of the ProjectData class to make the call to the newly created method.

Post any new methods source here and they can be included in a future release. 

Schemas: 

Several pre-defined schemas are provided. You can create more...just add them to them to the VersionSchemas.xml file. 

You can specify assembly and file versions to use different methods by specifying "assembly" and "file" as the name in two different detail sections for the schema. If you want to use the same for assembly and file versions, specify "assembly/file" as the name. To keep assembly and file versions synchronized, ensure the versions are identical before calling. 

Points of Interest

Nothing really interesting about the code. Just thought I'd provide it in case others wanted to use it.

History

Original: posted 04/19/2011

推荐.NET配套的通用数据层ORM框架:CYQ.Data 通用数据层框架
新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"