title: How to generate a file with version control information (TFS) during build
body: <p>I'm tired of not knowing what builds web application is built from when an issue is presented to me by QA. My proposed solution is to generate some static content as part of the build process that has useful information in it. Somebody could reference that file manually on the server and I think it would be nice to offer the ability the HTTP GET the content as <em>json</em> perhaps as part of the API.</p>
  
  <p>Seems simple right? I've done a lot of looking into doing this with Subversion in the past but I'm not familiar with the options for TFS. I realize that I'm really looking for two things, one to harvest the TFS information such as the repository, branch, changeset number, ... as well as a way to write content to a file all within a standard build process. Are there any existing MSBuild targets or tools I can pull in using something like Nuget to ensure that this is done for all builds whether they are local dev builds or ones done through a CI server which don't require any extra configuration or steps by the dev or the one setting up the CI server environment? What I'm hoping is that this is a common enough pattern that maybe somebody has already done this exact thing and packaged it for reuse or that the pieces are simple enough to piece together in a way that can be repeated as a general pattern for various types of .NET projects.</p>
  
  <p>UPDATE: I realized that one issue with the proposed solution is that whatever static file is generated, it would have to be added as a reference to the project in order to be picked up by the build process as content so that it is copied/published properly along with the rest of the web application. Perhaps a broken reference can be added to the project ahead of time that would be fulfilled after the project is built at least once. This is reminiscent of the old way that Package Restore used to work with NuGet.</p>
  
  <p>Related resources:</p>
  
  <ul>
  <li><a href="https://msdn.microsoft.com/en-us/library/ee847423.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow noreferrer">MSDN - Code Generation in a Build Process</a></li>
  <li><a href="https://stackoverflow.com/a/14523011/83658">StackOverFlow - MSBuild to copy dynamically generated files as part of project dependency</a></li>
  <li><a href="https://stackoverflow.com/questions/4690217/how-to-programmatically-get-information-about-branches-in-tfs">StackOverflow - How to programmatically get information about branches in TFS?</a></li>
  <li><a href="https://stackoverflow.com/questions/13598086/it-is-possible-to-get-tfs-change-set-number-from-the-local-file-system">StackOverflow - It is possible to get TFS change set number from the local file system?</a></li>
  <li><a href="https://stackoverflow.com/questions/26349371/tf-exe-info-versiont-does-not-get-latest">StackOverflow - tf.exe info /version:T does not get latest</a></li>
  </ul>