title: Change working directory of msbuild.exe
body: <p>I am executing MSBuild from a batch file.  The MSBuild script is in a different directory than the directory I want MSBuild to consider the working directory when running the script.  When invoking MSBuild.exe, how do I change its working directory?</p>
  
  <p><strong>Edit: More details</strong><br>
  Let's say I have an MSBuild script located on some other server.  I want to run a command thusly:  </p>
  
  <pre><code>msbuild.exe \\my_server\c$\My\Path\To\Scripts\TestScript.msbuild
  </code></pre>
  
  <p>I run that command with my command prompt at c:\temp.  Let's say my TestScript.msbuild has a  task to create a file.  The file has no path just a filename.  I would expect that the file gets created inside c:\temp.  But it doesn't it gets created next to the msbuild file that is sitting on the server.  This is the behavior I want to change.</p>
  
  <p><strong>Edit #2</strong><br>
  Here is the script I'm using in my test:  </p>
  
  <pre><code>&lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;   
      &lt;ItemGroup&gt;
          &lt;Files Include="HelloWorld.txt" /&gt;
      &lt;/ItemGroup&gt;
  
      &lt;Target Name="TouchFiles"&gt;
          &lt;Touch Files="@(Files)" AlwaysCreate="True" /&gt;
      &lt;/Target&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>I am going into a command shell CDing into c:\temp and then executing the script.  With or without the /p:OutDir switch that @Nick Nieslanik mentions, the HelloWorld.txt file appears in the folder where the *.msbuild file is and not c:\temp.</p>