Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AssemblyInfo.cs subversion and TortoiseSVN

I'm using TortoiseSVN and Visual Studio 2008. Is there any way to update my project's assemblyinfo.cs with svn's version in every build?

For example, 1.0.0.[svn's version] -> 1.0.0.12

like image 597
Babak Avatar asked Oct 25 '09 18:10

Babak


People also ask

What are the concepts of AssemblyInfo CS file?

AssemblyInfo. cs contains information about your assembly, like name, description, version, etc. You can find more details about its content reading the comments that are included in it.

How is AssemblyInfo CS created?

AssemblyInfo. cs file is created automattically when you create a windows application by Microsoft Visual Studio 2005. It is located under the folder "Properties".

What is SubWCRev?

SubWCRev reads the Subversion status of all files in a working copy, excluding externals by default. It records the highest commit revision number found, and the commit timestamp of that revision, it also records whether there are local modifications in the working copy, or mixed update revisions.


4 Answers

You could use the SubWCRev tool which comes with TortoiseSVN (also available separately).

Either run it from a command line or use the COM-Object it offers.

The SubWCRev command line tool replaces keywords inside a file with information from your svn working copy. An example is shown in the docs.

like image 76
Stefan Avatar answered Sep 17 '22 13:09

Stefan


I do this in my build script:

<SvnInfo LocalPath=".">
  <Output TaskParameter="Revision" PropertyName="BuildRev" />
</SvnInfo>
<FileUpdate Files="protobuf-net\Properties\AssemblyInfo.cs"
  Regex='(\[\s*assembly:\s*AssemblyVersion\(\s*"[^\.]+\.[^\.]+)\.([^\.]+)(\.)([^\.]+)("\)\s*\])'
  ReplacementText='$1.$2.$(BuildRev)$5' />

using the community build tasks. This essentially applies a regex to the AssemblyInfo.cs, replacing the current revision with the svn revision.

like image 28
Marc Gravell Avatar answered Sep 20 '22 13:09

Marc Gravell


You could use the $Rev$ svn keyword but that will give you the last revision of the file, I think you want to get the HEAD revision number.

Give a look to this question:

  • How do I sync the SVN revision number with my ASP.NET web site?
like image 34
Christian C. Salvadó Avatar answered Sep 18 '22 13:09

Christian C. Salvadó


How do you feel about a Visual Studio addin doing it?

like image 43
popester Avatar answered Sep 20 '22 13:09

popester