简体   繁体   English

获取TFS buildNumber

[英]Get TFS buildNumber

I need to show the build number a page. 我需要在页面上显示内部版本号。 Different version of this page should show its corresponding build number. 此页面的不同版本应显示其相应的内部版本号。 How can I do this? 我怎样才能做到这一点?

My thinking is that I configure the build in some place and the build can store the version number in the source code and my program will read this. 我的想法是,我在某个地方配置了构建,并且构建可以将版本号存储在源代码中,并且我的程序将读取此版本。

You can enable assembly versioning inline with build number which will update the AssemblyInfo.cs file. 您可以内联启用带有版本号的程序集版本控制,这将更新AssemblyInfo.cs文件。 Your program can read the build number from this file. 您的程序可以从该文件读取内部版本号。

To get the build version simply use the following property 要获取构建版本,只需使用以下属性

$(BUILD_NUMBER)

Perhaps you want to use it as part of the version of your assemblies: 也许您想将其用作程序集版本的一部分:

http://msbuildtasks.tigris.org/ http://msbuildtasks.tigris.org/

<UsingTask AssemblyFile="$(MSBuildCommunityTasksLib)" TaskName="MSBuild.Community.Tasks.AssemblyInfo" />

<MSBuild.Community.tasks.AssemblyInfo OutputFile="$(AssemblyVersionFilePath)"
      CodeLanguage="C#"
      AssemblyFileVersion="$(FileVersion)"
      AssemblyInformationalVersion="$(InformationalVersion)"
      AssemblyVersion="$(SemanticVersion)" />

As part of customising the build process to do assembly versioning I usually create a version.txt file that I can deploy with the site. 在自定义构建过程以进行程序集版本控制的过程中,我通常会创建一个version.txt文件,该文件可与站点一起部署。 In the global.asax I read the version at app startup and then simply use that value in a footer for each page where I want it shown. 在global.asax中,我在应用程序启动时阅读了该版本,然后仅在要显示该页面的每个页脚的页脚中使用该值。 Alternatively I may read the version info from one of the assemblies I know I'm deploying with the site and use that instead. 或者,我可以从我知道要与该站点一起部署的程序集之一中读取版本信息,并改用它。 Either way works. 无论哪种方式都行。

If you need help with automatically versioning your build, you could have a look at my blog post on it 如果您需要有关自动版本化构建的帮助,则可以查看我的博客文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM