title: Occasionally occurring MSBUILD : error MSB3428:
body: <p>I have a PowerShell script that does the following:</p>
  
  <ol>
  <li>Upgrades an old Visual Studio solution using devenv.exe.</li>
  <li>Builds the upgraded Visual Studio solution using MSBuild.</li>
  </ol>
  
  <p>If I run this script, I get an error stating "MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
   To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
  l Studio 2005 or 3) add the location of the component to the system path if it
  is installed elsewhere."</p>
  
  <p>What is strange to me is that I can successfully upgrade and build the solution if I rerun the script after seeing the error message. I've tried running the script on multiple machines, and I am seeing the error message only the first time I try executing the script. Subsequent attempts are successful. </p>
  
  <p>I am using Windows 10, PowerShell version 5.1 and Visual Studio 2015 Community. </p>
  
  <p>Here is the relevant snippet of code:</p>
  
  <pre><code>        $DevenvExe = 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe'
          $MsBuildExe = 'C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe'
          $SolutionPath = "$CurrentPath\portaudio\build\msvc\portaudio.sln"
  
          &amp; $DevenvExe $SolutionPath /upgrade
          &amp; $MsBuildExe $SolutionPath /p:Configuration=Release /p:Platform=x64 /nr:false /m:4
          if ($?) {
              Write-Host "Success"
          } else {
              # This piece of code executes, followed by the MSBUILD error
              Write-Host "PortAudio did not successfully build." -ForegroundColor Red
              Write-Host "Please refer to the Operation Manual for instructions to build PortAudio." -ForegroundColor Red
          }
  </code></pre>
  
  <p>What could be going on that is causing the error to happen on the first iteration of execution, but successful on all other attempts?</p>