将Tortoise SVN版本号链接到汇编版本

我正在使用Visual Studio中的C#.net开发一个程序,并使用tortoise SVN控制它。

目前我正在根据内部版本号创建程序集版本。

有没有办法可以将项目组装版本的最后一部分链接到乌龟SVN的版本号,例如:

伪代码:

[assembly: AssemblyVersion("1.0.0."+SvnRevisionNumber.ToString())] 

这将确保我的程序集以其命名,而不是它们的构建号,但是在提交到存储库的最后一个修订号之后。

我使用的是在post build事件中调用cmd文件:

 @echo off if %1x==x goto ERROR SET ProjectDir=%1 SET SubWCRev="C:\Program Files\TortoiseSVN\bin\SubWCRev.exe" if exist %SubWCRev% goto USESUBWCREV REM Default to copying a default version copy %ProjectDir%\Properties\AssemblyInfo.default.cs %ProjectDir%\Properties\AssemblyInfo.cs echo default goto END REM We don't want to modify AssemblyInfo.cs every time, only when a revision REM changes. Thus, we want to first compare the last compiled revision with REM the current revision, and only update if they've changed. :USESUBWCREV %SubWCRev% %ProjectDir% %ProjectDir%\Properties\rev.subwcrev-template %ProjectDir%\Properties\rev.current.tmp if exist %ProjectDir%\Properties\rev.last-build.tmp goto CHECKREV goto NEWREV REM Fetch the current revision and compare to last-build revision :CHECKREV fc %ProjectDir%\Properties\rev.last-build.tmp %ProjectDir%\Properties\rev.current.tmp > NUL REM Only update if it's a new revision if errorlevel 1 goto NEWREV goto END REM Current revision doesn't match last-build revision. Update! :NEWREV echo newRev if exist %ProjectDir%\Properties\rev.last-build.tmp del %ProjectDir%\Properties\rev.last-build.tmp copy %ProjectDir%\Properties\rev.current.tmp rev.last-build.tmp echo use template %SubWCRev% %ProjectDir% %ProjectDir%\Properties\AssemblyInfo.subwcrev-template.cs %ProjectDir%\Properties\AssemblyInfo.cs echo done goto END :ERROR echo Usage: %0 project_dir echo. echo For example: echo %0 C:\projects\MyProjectDir echo. goto END :END 

你可以使用这样的东西来获得svn版本号。

       

它几乎将svn修订版输出到xml文件,然后xml查看以获取修订版号。

您可以将其用作预构建事件,然后使用新版本号更新assemblyinfo。

另请参阅此主题以获取更多信息.NET程序集中的SVN修订版本,无需CC.NET

我正在研究MSbuild扩展包。

有一个Subversion扩展,它会自动为你检索SVN的东西。 链接在这里: MSBuild Subversion扩展帮助

其次,您可以将其与其他扩展一起用于以编程方式设置目录的版本。 根据您在SCM系统中的布局,您可以像这样在其自己的存储库中对每个目录进行版本化。

检查C#项目文件中的空格和引号。

  if exist "C:\Program Files\TortoiseSVN\bin\SubWCRev.exe" "C:\Program Files\TortoiseSVN\bin\SubWCRev.exe" "$(ProjectDir)." "$(ProjectDir)Properties\AssemblyInfo.Base.cs" "$(ProjectDir)Properties\AssemblyInfo.cs"