title: Why does MSBuild only work properly in the developer command prompt?
body: <p>I'm building a project locally using <code>msbuild.exe</code> like:</p>
  
  <pre><code>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe MyProject.csproj
  </code></pre>
  
  <p>When I execute it through the <strong>Developer Command Prompt</strong>, everything works as expected.</p>
  
  <p>However, when I execute it through the standard <strong>Command Prompt</strong>, I get an error saying:</p>
  
  <blockquote>
    <p>The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" was not found.</p>
  </blockquote>
  
  <p>If I look up that folder path, I can indeed verify it's <strong>invalid</strong> (I only have VS 2015 installed on the machine).</p>
  
  <p>So why isn't it working in <strong>Command Prompt</strong>, or conversely: why <em>is</em> it working in <strong>Developer Command Prompt</strong>?</p>
  
  <p><strong>Edit:</strong> The <strong>.csproj</strong> file is pretty much the Visual Studio 2015 default for an ASP.NET 4 website, and it specifies:</p>
  
  <pre><code>&lt;PropertyGroup&gt;
    &lt;VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''"&gt;10.0&lt;/VisualStudioVersion&gt;
    &lt;VSToolsPath Condition="'$(VSToolsPath)' == ''"&gt;$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)&lt;/VSToolsPath&gt;
  &lt;/PropertyGroup&gt;
  &lt;Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /&gt;
  </code></pre>
  
  <p>To me it seems it would default to <strong>10.0</strong> if <code>VisualStudioVersion</code> isn't set, but judging from the error message it's assuming VS version <strong>12.0</strong>.</p>
  
  <p>I realize I could just modify the <strong>.csproj</strong> file, replacing <strong>12</strong> with <strong>14</strong>, but I'd rather not go for a workaround, but instead understand why it's working in the <strong>Developer Command Prompt</strong>, but not the standard one.</p>
  
  <p>I'm guessing it potentially has to do with different environment variables, or something along those lines?</p>