我现在已经使用SVN一段时间了。最近在一个项目中我开始使用TFS。在构建过程中,我希望将版本号附加/更新到项目输出上。我在主页面上进行这个操作,以便在应用程序中清晰可见。由于应用程序可能在多台机器上运行,了解正在运行的版本是很方便的信息。
在SVN世界中,我通过以下方式实现:
<!-- 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.SVN版本号更新masterPage.master文件。
如果使用TFS作为源控制方式,该如何实现呢?如何获取TFS构建号?