gpt4 book ai didi

c# - 将 Tortoise SVN 修订号链接到程序集版本

转载 作者:可可西里 更新时间:2023-11-01 03:01:31 24 4
gpt4 key购买 nike

我正在 visual studio 中用 C# .net 开发一个程序,并使用 tortoise SVN 对其进行版本控制。

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

有没有一种方法可以将项目程序集版本的最后部分链接到 Tortoise SVN 中的修订号,例如:

伪代码:

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

这将确保我的程序集是根据提交到存储库的最后修订号命名的,而不是它们的内部版本号。

最佳答案

我使用的是在构建后事件中调用一个 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

关于c# - 将 Tortoise SVN 修订号链接到程序集版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17713513/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com