views:

118

answers:

1

Does anyone know what the syntax is to use the file revision keyword within the code in C#? I know how to use it in SQL Server but I can't seem to get the syntax right. I have already added the property to the file in which I would like to display the version.

Thanks!

badPanda

+2  A: 

You C# files should contain $LastChangedRevision: $ to get the SVN revision added. However, you also need to set the svn:keywords property correctly for the files in which you want that value to be expanded.

For example, the following will result in a string containing the revision.

string revision = "$LastChangedRevision: $";

The svn:keywords property should include the LastChangedRevision in its space-separated list of values.

You can make this automatic for the cs extension by editing the TortoiseSVN configuration. To do this, go to the TortoiseSVN explorer menu and select Settings.... Then on the General tab, click the Edit button next to Subversion configuration file:.

Scroll down and add a line like this one into the [auto-props] section (just an example, you may have more or less keywords and you may also set other properties):

*.cs = svn:keywords=LastChangedDate LastChangedBy LastChangedRevision Id URL;
Jeff Yates
Thanks Jeff! However, what I am actually having trouble with is accessing the property in my code. What is the syntax to, say, output that $Revision: $ as a string?
badpanda
@badpanda: string revision = "$LastChangedRevision: $"; Check in the file and out again, and a revision will be filled in.
calmh
There we go! Thanks!!
badpanda