Take the 2-minute tour ×

At my current client we have some legacy ASP.Net web site projects. I am in the process of introducing automatic versioning for our builds and was wondering of how to best do this with web site projects in Team City?

I am currently using Team City's %build.number% variable (set through project build template) as the authoritative version number for a build. For any .NET project that produces assemblies it's hassle-free to use "AssemblyInfo Patcher" Build Feature in Team City but this does not work for web site projects since they do not produce assemblies.

So, any suggestions? I am already using Powershell and psake in my builds so creating scripts that use %build.number% is not a problem, it is more a question of how to inject this into the web site project in a "nice" manner.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I attempted several solutions but ended up with using the version number of a dependent assembly that gets set by Team City during the build. I added a class to the assembly and it looks something like this:

public class VersionUtils
    private readonly ILog _logger;

public VersionUtils() { _logger = LogManager.GetLogger("VersionLogger"); } public string GetWebAppVerison() { string version = "unknown version"; var assembly = Assembly.GetAssembly(typeof(VersionUtils)); try { version = assembly.GetName().Version.ToString(); } catch(Exception ex) { _logger.Warn("Could not find or read version number from " + assembly.GetName(), ex); } return version; }

share|improve this answer
add comment

Your Answer


