我已经使用 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.SVNVERSION 标记更新 masterPage.master 文件。
如何使用 TFS 作为源代码控制来实现这一点。如何获取 TFS 内部版本号?