简体   繁体   中英

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. 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/

<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. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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