views:

998

answers:

4

Is it possible to update the version number(AssemblyVersion("1.0.2.1")) insdie AssemblyInfo.cs outside visual studio???(Maybe using a script or a batch file)

+1  A: 

I used to have a PowerShell script that would write the version number out to "AssemblyVersion.cs", like this:

// DO NOT EDIT
// Generated by UpdateVersion.ps1.
[AssemblyVersion("1.0.2.1")]

The version number was updated in all projects/assemblies at once this way. The canonical number was stored elsewhere.

It's trivial to write, but varies depending on your exact needs, so I won't try to post it here.

Jay Bazuzi
+1 for using PowerShell over old-style batch files! :-)
marc_s
@jay any sample of UpdateVersion.ps1 ?? What I need install for use Powershell scripts ?? I have Winxp sp2.
alhambraeidos
@alha: I don't have access to it any more, sorry. Luckily this isn't a difficult problem.
Jay Bazuzi
A: 

You can simply use any search and replace tool or write one yourself.

For the current porject (that is built with msbuild) I'm using a custom build step (self written as it is small and simple) that searches for AssemblyVersion and replaces that in the AssemblyInfo.cs files.

froh42
+2  A: 

I have used UpdateVersion in the past to update the version number as part of a build script before. If you use subversion you can also use SubWCRev.exe from TortoiseSVN to update the version number to include the SVN revision number.

Richard Slater
+2  A: 

It can also be done from MSBuild..

Check out the AssemblyInfo task here: MSBuild tasks

We use it from CruiseControl.net it's very straightforward to use.

Dog Ears