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?

Comment actions Permalink


I would suggest to create additional build step which puts the value of MyWebSite to the sites footer.

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: ""
- 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;

Please sign in to leave a comment.