AssemblyInfo.cs subversion and TortoiseSVN

后端 未结 7 983
情歌与酒
情歌与酒 2020-12-24 16:03

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\'

7条回答
  •  庸人自扰
    2020-12-24 16:19

    Yes, you can add a pre-build event that calls a script which

    • calls svn info to extract the current revision number (if you do an update before, you can directly include the keyword $Revision$ in a file, check also this post);
    • modifes your Properties\AssemblyInfo.cs file accordingly.

    What I usually do is transform a AssemblyInfo.cs template when the project is built. The script is necessary to adapt the form of $Revision$ to the syntax of this file, unfortunately.

    The interesting properties are (where the template strings are between '$'):

    [assembly: AssemblyVersion("$v$.$build$.$Last Changed Rev$")]
    [assembly: AssemblyFileVersion("$v$.$build$.$Last Changed Rev$")]
    

    Edit: svn info is part of the standard SVN client, not TortoiseSVN as pointed out in another post. Easy to install though. However, TortoiseSVN comes with SubWCRev.exe which transforms a file with keyword substitution, so it would do the trick if you update your local copy.

提交回复
热议问题