链接乌龟SVN版本号为集版本 [英] Linking Tortoise SVN revision number to assembly version

查看:427
本文介绍了链接乌龟SVN版本号为集版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个程序用C#.net的Visual Studio和版本乌龟SVN控制它。

I'm developing a program in C# .net in visual studio and version controlling it with tortoise SVN.

在present基础上,内部版本号我创建的程序集的版本。

at present I'm creating the assembly version based on the build number.

有没有一种方法可以让我的项目集版本的最后一部分链接到乌龟SVN版本号代替,例如:

Is there a way I can link the final part of a projects assembly version to the revision number in tortoise SVN instead, eg:

伪code:

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

这将保证我的程序集被命名后,没有自己的版本号,但提交到库的最后一个版本号之后。

This would ensure that my assemblies were named after, not their build number, but after the last revision number committed to the repository.

推荐答案

我用的是停靠后生成事件一个CMD文件:

What I use is calling a cmd file at the post build event:

@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版本号为集版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆