Integrating revision number with .NET assembly

Giorgos Keramidas keramida at ceid.upatras.gr
Fri Aug 1 06:40:57 CDT 2008


On Fri, 1 Aug 2008 13:13:14 +0200, Alexander Gräf <alex at graef.cc> wrote:
>> -----Original Message-----
>> From: Giorgos Keramidas [mailto:keramida at ceid.upatras.gr]
>> Sent: Friday, August 01, 2008 11:15 AM
>> To: Alexander Gräf
>> Cc: mercurial at selenic.com
>> Subject: Re: Integrating revision number with .NET assembly
>>
>> "hg identify"?
>
> Thank you for that pointer. I created a simple .js-File:
>
> Version.js:
>
> var fso = new ActiveXObject("Scripting.FileSystemObject");
> var shell = new ActiveXObject("WScript.Shell");
> var hgIdentify = shell.Exec("hg identify --num");
> var rev = hgIdentify.StdOut.ReadAll();
> var outFile = fso.CreateTextFile("Version.cs", true);
> outFile.WriteLine("using System.Reflection;");
> outFile.WriteLine("[assembly: AssemblyVersion(\"0.1."+String(rev).replace("\n","").replace("+","")+".*\")]");
> outFile.WriteLine("[assembly: AssemblyFileVersion(\"0.1."+String(rev).replace("\n","").replace("+","")+".0\")]");
> outFile.Close();
>
> And then included a pre-build event command line in Visual Studio
> 2008:
>
> cd $(ProjectDir)Properties
> cscript.exe Version.jse
>
> It writes a Version.cs file with the current revision number in
> it. Not pretty but good enough for me...

Nice.  I'm glad I could help :)




More information about the Mercurial mailing list