Fix bug MSBUILD : error MSB3428: Could not load the Visual C++ component “VCBuild.exe” …

So here it is. I have tested these steps multiple times on (each time) newly created Windows 7 SP1 VMs with IE8.

Scenario: I have a brand new Windows system, what to do?

[Only if it is Windows 7 then and you don’t already] Download .NET Framework 4.5.1 and run the installer.
Download Build Tools 2015, run the build installer.
Download Visual C Build Tools 2015 Preview, run the installer, select Custom, click Next and check both SDKs (8 and 10), click Next and then Install.
Launch regedit Navigator to HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0. Add string key VCTargetsPath key, set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140
npm config set GYP_MSVS_VERSION 2015
Download and install latest node.js.
Download and install Python 2.7.x.
Open cmd and run npm config set msvs_version 2015 –global.

Hopefully it is a temporary registry fix and they will fix it before Build Tools get out of Technical Preview status. Out of 4 times it created that registry value once.

Start > Run > cmd (and press Ctrl+Shift+Enter to Run as Administrator):
For 64-bit Windows

:: copy paste this command and press enter
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7 /v 14.0 /t REG_EXPAND_SZ /d ^%programfiles(x86)^%"\Microsoft Visual Studio 14.0\\"

For 32-bit Windows

:: copy paste this command and press enter
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7 /v 14.0 /t REG_EXPAND_SZ /d ^%programfiles^%"\Microsoft Visual Studio 14.0\\"

Now install the package like npm install selenium-webdriver and it should work!

My installation is not brand new, I had some related stuff installed and now I am getting MSB4019 or MSB8020.

This means somehow you have incorrect version of msbuild in PATH. To fix that, put C:\Program Files (x86)\MSBuild\14.0\Bin; at the beginning of PATH under System Environment Variables. To do it quickly (without making permanent change), run SET PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin;%PATH% in command prompt in case of 64-bit Windows or %ProgramFiles%\MSBuild\14.0\Bin; in case of 32-bit Windows. Then run your intended npm install command.

Finally, what to expect?

Expect every package which requires C/C++ code compilation at the time of installation to succeed on Windows, exactly as they compile at installation time on Unix-like operating systems, except those which are not supporting Windows at all (yet?) such as node-gd. For such packages, you can find their repository URL on package’s http://npmjs.org/ page and find the Windows support status in their issue tracker.

From issue in “Windows users are not happy”

Advertisements

One thought on “Fix bug MSBUILD : error MSB3428: Could not load the Visual C++ component “VCBuild.exe” …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s