MSBuild TFS内部版本号 [英] MSBuild TFS Build Number

查看:89
本文介绍了MSBuild TFS内部版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用SVN已有一段时间了.最近在一个我正在使用TFS的项目中.对于构建,我想在项目输出上附加/更新构建版本号.我在母版页上执行此操作,以便在应用程序上清晰可见.由于该应用程序可以在多台计算机上运行,​​因此可以方便地了解正在运行哪个版本的信息.

I have been using SVN for a little while now. recently on a project I am using TFS. With the builds I like to append/update the build version number on the project output. I do this on the masterpage so that it is clearly visible on the application. Since the application could be running on multiple machines, it is handy information on which verison are running.

我在SVN世界中达到以下目标:

I achive this in SVN world as:

  <!-- Import of the MSBuildCommunityTask targets -->
    <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
    <!-- to AssemblyInfo to include svn revision number -->
    <Target Name="BeforeBuild">
      <SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="$(ProgramFiles)\CollabNet Subversion Client">
        <Output TaskParameter="Revision" PropertyName="Revision" />
      </SvnVersion>
      <Time>
        <Output TaskParameter="Year" PropertyName="Year" />
        <Output TaskParameter="Month" PropertyName="Month" />
        <Output TaskParameter="Day" PropertyName="Day" />
      </Time>
      <FileUpdate Files="MasterPage.master" Regex="svn revision: (\d+)\.(\d+)\.(\d+)\.(\d+)" ReplacementText="svn revision: $(Year).$(Month).$(Day).$(Revision)" />
    </Target>

正如您在上方看到的那样,"BeforeBuild"任务使用YYYY.MM.DD.SVNVERSION标记更新masterPage.master文件.

As you can see above the "BeforeBuild" task updates the masterPage.master file with the YYYY.MM.DD.SVNVERSION stamp.

如何使用TFS作为源代码控件来实现这一点.如何获得TFS的内部版本号?

How can I achive this with TFS as the source control. How do I get the TFS build number?

推荐答案

假设您是指团队建设,则$(BuildNumber)属性包含当前的内部建设编号.

Assuming you mean Team Build, the $(BuildNumber) property contains the current build number.

请参见 http: //blogs.msdn.com/aaronhallberg/archive/2008/02/12/team-build-2008-property-reference.aspx 以获得可用属性的完整参考.

See http://blogs.msdn.com/aaronhallberg/archive/2008/02/12/team-build-2008-property-reference.aspx for a full reference of available properties.

如果您仅运行MSBuild,我不认为它会生成/应用一个总的内部版本号(每个项目的AssemblyInfo.cs [默认情况下]文件中都有一个单独的,可能会自动递增的版本号) .您可以在运行时使用System.Reflection.Assembly类动态获取特定程序集的版本号.

If you're just running MSBuild, I don't believe it generates/applies an overall build number (each project will have an individual, possibly auto-incremented, version number in its AssemblyInfo.cs [by default] file). You can dynamically get this version number for a specific assembly using the System.Reflection.Assembly class at runtime.

从TFS 2010开始,'BuildNumber'变量不再由TFS自动传递给MSBuild进程. TFS 2010现在使用Windows Workflow作为其内部构建引擎,因此,如果要构建号,则必须修改构建定义以包括它,如

As of TFS 2010, the 'BuildNumber' variable is no longer automatically passed to the MSBuild process by TFS. TFS 2010 now uses Windows Workflow as its internal build engine, so if you want the build number, you'll have to modify your build definition to include it, as mentioned in this MSDN article.

这篇关于MSBuild TFS内部版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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