 <p>Okay here's what I wound up doing. It's not very elegant, but it works. I created a pre-build step that looks like this:</p> <pre><code>echo namespace Some.Namespace &gt; "$(ProjectDir)\CiInfo.cs" echo { &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo ///^&lt;summary^&gt;Info about the continuous integration server build that produced this binary.^&lt;/summary^&gt; &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo public static class CiInfo &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo { &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo ///^&lt;summary^&gt;The current build number, such as "153"^&lt;/summary^&gt; &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo public const string BuildNumber = ("%BUILD_NUMBER%" == "" ? @"Unknown" : "%BUILD_NUMBER%"); &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo ///^&lt;summary^&gt;String of the build number and build date/time, and other useful info.^&lt;/summary^&gt; &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo public const string BuildTag = ("%BUILD_TAG%" == "" ? @"nohudson" : "%BUILD_TAG%") + " built: %DATE%-%TIME%"; &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo } &gt;&gt; "$(ProjectDir)\CiInfo.cs" echo } &gt;&gt; "$(ProjectDir)\CiInfo.cs" </code></pre> <p>Then I added "CiInfo.cs" to the project, but ignored it from version control. That way I never have to edit it or commit it, and the project always has a constant available that is the latest build number and time.</p>