title: Xml file not copying to test output directory
body: <p>Visual Studio 2010, x64 machine, using the built-in web server to host a WCF service with a set of unit tests using the built-in test framework.</p>
  
  <p>I have an XML file that my tests need to load to run.  I've included this file in the test project, and have the file set to 'content' and 'always copy to output directory'.  This file copies to the bin\debug directory fine.</p>
  
  <p>When I execute the tests, however, the xml file is not there.  Instead of looking in the  project's bin\debug folder, it looks for it in the test's working directory, C:\Projects\SAP Reapprovals\TestResults\name_machine 2010-12-06 13_45_43\Out".  The file hasn't been copied there.</p>
  
  <p>Is there a way to force this file to copy, or do I need to fully qualify the reference from within the test?</p>
  
  <p>TIA!<br />
  James</p>
  
  <p><br />
  <strong>Update</strong><br />
  I set the <code>DeploymentItem</code> attribute, but the file still doesn't copy.  But that sure looks like what I want... any ideas why that isn't working?</p>
  
  <p>My test code:</p>
  
  <pre><code>[TestMethod]
  [DeploymentItem("SAP - GS3 format.xml")]
  public void TestProcessSapRoles() {
  
      //  I get a 'file not found' error here, and when 
      //  I check the output directory, it isn't there
      XElement rolesRoot = XElement.Load("SAP - GS3 format.xml");
  
  }
  </code></pre>
  
  <p><br />
  <strong>ANSWERS:</strong><br />
  Thanks go out to CPedros, with his help I've zoomed in on this a bit.  I ran SysInternals' Process Monitor, to see where it was looking for my xml file.  Here's what I found:</p>
  
  <p>When I ran the tests using ctrl+r,ctrl+t (debug tests in current context), <i>visual studio </i><b>ignored</b><i> the </i><code>DeploymentItem</code><i> attribute completely</i> and did not even <i>try</i> to copy the file anywhere.  In this case I got a "File Not Found" exception when I tried to open it for reading.  Visual studio created a temporary working directory for the tests, but there was only one file in it, AgentRestart.dat.</p>
  
  <p>When I ran the tests using the 'Run Unit Tests' button in my toolbar (not sure what test option that is), Visual Studio did not copy the file over, but referenced it directly from the project directory.  The test passed, and no temporary working directory was created.  </p>
  
  <p>When I ran the test from the menu option "run -> tests in current context" (run, not debug), a temporary working directory was created, and the xml file and all executables were copied to it.  The test passed.  </p>
  
  <p>When I edited Local.testsettings (under a Solution Items folder under my tests folder), I chose 'Deployment' from the left menu, and added the xml file.  It was added as [solution directory]\[project directory]\file.xml.  I removed the <code>DeploymentItem</code> attribute.  Now I was able to debug the tests; the xml file and all executables were copied to the temporary directory created for the test.</p>
  
  <p><b>TLDR:</b>  Visual Studio is ignoring the <code>DeploymentItem</code> attribute for certain ways of running the test.  The solution is to edit <code>Local.testsettings</code>, the <code>Deployment</code> menu, and add the file by hand.  </p>
  
  <p>Thanks for the help!  I'm giving CPedros credit for his answer, as it was the most helpful in resolving this.</p>