title: How to run Code Coverage on a nightly build with TFS 2008/Visual Studio 2010
body: <p>I currently have a solution with a number of projects which include Unit Tests.
  We've got a CI build and a separate Scheduled build and I would like to be able to run Code Coverage on the latter (not the CI).</p>
  
  <p>At the moment we are using Visual Studio 2010 and TFS 2008. None of these can be changed.
  I've looked around for hours and lots of suggestions mention a Process tab to select in the Build Definition however further investigation shows that the combination of VS/TFS that we have does not have this option.</p>
  
  <p>Another source says to modify some testsettings such that they contain the Code Coverage option (which I have done) and then define the Test Settings file in the build - but I have no idea how to do this (<a href="http://www.codewrecks.com/blog/index.php/2010/06/14/running-code-coverage-in-tfs2010-builds/" rel="nofollow">http://www.codewrecks.com/blog/index.php/2010/06/14/running-code-coverage-in-tfs2010-builds/</a>).</p>
  
  <p>I have a testsettings configuration that will run code coverage locally so my issue is that I need the MSBuild TFSBuild.proj file to know which testsettings file to use when running it's tests (through the <code>&lt;RunTest&gt;true&lt;/RunTest&gt;</code> option).</p>
  
  <p>Any help on this would be greatly appreciated. I've trawled through the various other proposed solutions but none seem to match this. They either use a better version of TFS, or do something else.</p>
  
  <p>EDIT. I suspect I might be restricted to using an <code>Exec</code> task within the build script and running the <code>Vsperfmon.exe</code> command with some arguments. If this is the case please provide an example because I've no idea how to capture the results from this command and tie them to my Scheduled build.</p>
  
  <p>Thanks all.</p>