ytrstu / gyp

Automatically exported from code.google.com/p/gyp
0 stars 0 forks source link

MSVSVersion looks for Windows SDK in a wrong place #457

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install node.js on Win7 x64 machine
2. Install Windows SDK 7.1
3. Run "npm install -g ws"

What is the expected output? What do you see instead?
 * Expected: compilation goes through
 * Actual: compilation fails with the error message below

What version of the product are you using? On what operating system?
 * node-gyp@1.0.1 via npm@1.4.23 on node.js@0.10.31
 * MS Windows 7 Professional x64 SP1
 * Windows SDK 7.1 downloaded from [1] and installed with default options

Please provide any additional information below.

ERROR MESSAGE
C:\Program Files 
(x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(297,5): warning 
MSB8003: Could not find WindowsSDKDir variable from the registry.  
TargetFrameworkVersion or PlatformToolset may be set to an invalid version 
number. 
[C:\Users\Mikhail\AppData\Roaming\npm\node_modules\ws\build\bufferutil.vcxproj]
C:\Program Files 
(x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(146,5):
 error MSB6006: CL.exe avbröts med koden -1073741515. 
[C:\Users\Mikhail\AppData\Roaming\npm\node_modules\ws\build\bufferutil.vcxproj]

It seems a lot of users are hit by this issue and the workaround is to invoke 
SetEnv.cmd manually as per [2] I've tried to track down the root cause of this 
problem and I think I know what causes it.

As follows from MSVSVersion source code [3], it looks for Windows SDK paths in 
several places in the registry. There is logic for the case when Visual Studio 
is installed along with Windows SDK as well as for the case when only Windows 
SDK is installed. It appears, that the latter part has a bug. The code looks 
for the path to Windows SDK in 
HKLM\Software\(Wow6432Node\)Microsoft\VisualStudio\SxS\VC7\10.0 which points to 
a non-existent directory C:\Program Files (x86)\Microsoft Visual Studio 
10.0\VC\. It should instead look at 
HKLM\SOFTWARE\(Wow6432Node\)Microsoft\Microsoft 
SDKs\Windows\v7.1\InstallationFolder which points to C:\Program Files\Microsoft 
SDKs\Windows\v7.1\. This directory indeed contains the Bin\SetEnv.Cmd file that 
sets environment variables. I've found the right registry key thanks to Dan 
Malcolm at StackOverflow [4].

[1] http://www.microsoft.com/en-us/download/details.aspx?id=8279
[2] https://gist.github.com/kosmobot/6020327
[3] 
https://code.google.com/p/gyp/source/browse/trunk/pylib/gyp/MSVSVersion.py#330
[4] 
http://stackoverflow.com/questions/2748974/how-to-set-sgen-toolpath-in-msbuild-t
o-target-3-5-framework/5701714#5701714

Original issue reported on code.google.com by mikhail....@gmail.com on 9 Sep 2014 at 3:00