Using changeset number inside ASP.NET site CI build

I have configured a TeamCity project to retrieve bits from TFS and publish an ASP.NET web site. I'd like to display the number of the TFS changeset used by TeamCity in the footer of the generated website, like so: "MyWebSite v1.0.[changeset number]. Could you please suggest a way to achieve this?

2 comments
Comment actions Permalink

Hi,

I would suggest to create additional build step which puts the value of MyWebSite v1.0.%system.build.vcs.number% to the sites footer.

0
Comment actions Permalink

Actually, what I did to solve this was:
- went to Build Features
- "Add build feature" > chose AssemblyInfo patcher
- Assembly informational version format: "TC.%system.build.number%"
- Patch GlobalAssemblyInfo: checked

(my VS solution contains a GlobalAssemblyInfo.cs shared accross projects)

I can now display the TC build number and TFS changeset in my published app by reading the value injected by TeamCity in my GlobalAssemblyInfo.cs:

var fileVersionAttribute = Attribute.GetCustomAttribute(typeof(AssemblyInfo).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
var assemblyInformationalVersion = fileVersionAttribute != null ? fileVersionAttribute.InformationalVersion : null;
0

Please sign in to leave a comment.