title: How can tests reference external resources in a parent source directory in a TFS 2012 build?
body: <p>I'm setting up a TFS 2012 build agent and have run into a small problem with unit tests that reference external files. (Yes, yes, this is bad...no arguments there! I still have to get a build running) The tests are using the MSTest (VisualStudio.TestTools.UnitTesting) framework.</p>
  
  <p>Currently, there is a <code>Resources</code> folder under the solution root, and all the tests (which are unfortunately at varying depths in subdirectories) load files with some level of relative paths (<code>..\\..\\..\\Resources\\resource.txt</code>).</p>
  
  <p>TFS, as you know, copies <strong>all</strong> output to a <code>bin</code> folder that is at the same level as <code>src</code>, which has the required <code>Resources</code> folder. There is no way to copy this folder high up enough in the directory structure so the tests pass for the build agent.</p>
  
  <p>I am hoping that either of these questions can give me a stop-gap solution to this problem:</p>
  
  <ol>
  <li><p>Is there any environment variable (or something similar) that I could use to detect that the unit test is being run through a TFS build agent and change the path to the resource file in code accordingly?</p></li>
  <li><p>Is there a simple way to tell TFS to output files into the <code>bin</code> folder with the same hierarchy as they would have normally been if built in Visual Studio? (The reason I say <em>simple</em> is because I've found some rather long build modifications that could probably handle this)</p></li>
  </ol>