25
votes

I cannot build my project in Visual Studio 2012. The error is:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppBuild.targets(344,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number."

I have installed Windows SDK, and have tried to reinstall and to repair, and have even tried to enter the registry string key "WindowsSDKDir" to the registry. (HKLM/SOFTWARE/Wow6432Node/Microsoft/Microsoft SDKs/v7.1 with value C:\Program Files\Microsoft SDKs\Windows\v7.1).`

Is it a registry issue, or something else? I've tried searching for those registry keys and re-installing my Windows SDK but neither helped.

11
Was it a Visual Studio 2010 project originally? If so, it might still be set to use the VS2010 toolset in the general tab in Project PropertiesThe Dark
No, It is not originally a 2010 project, In fact, I made a new project in VS2012, and it still came up with this error.clashoftornados
Check the settings in Project Properties - Configuration Properties - General - Platform Toolset. Make sure it is set to Visual Studio 2012 (or just try changing it to something else).The Dark
It was set to visual studio 2012. I switched it to WindowsSDKv7.1 and go this error : "1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.targets(57,5): error MSB6006: "CL.exe" exited with code -1073741515."clashoftornados
Why this question does not have accepted answer ? How will it help to others who are having similar issue ?Rayon

11 Answers

17
votes

I was trying to get a script to compile for Script Hook V - GTA .NET Library.

I spent about 2 hours trying to figure out why it wouldn't work. Here is how I got it to build:

I right clicked on the project and selected properties:

Step1

Under Configuration Properties -> General -> Platform Toolset

I selected the dropdown and selected the only other one available

(For me it was Visual Studio 2013 - Windows XP (v120_xp))

Platform Toolset

After that I was able to fly my car normally:

Weeee

Hope this helps someone else trying to do the same thing.

10
votes

I had the same issue with Visual Studio 2013 ( no Service-packs installed ). Apparently during installation it needs an active internet connection or the sdk-path might be missing.

Just go into your control panel / programs / programs & features - and select "Microsoft Visual Studio xxx 2013", right-click-change and then "repair". It will take a few minutes but afterwards the sdk-path is correct.

9
votes

I have been having this issue lately when trying to install certain Node.js packages! I finally fixed it by adding the correct path to the registry variable!

The easiest way to fix it is by setting it with a simple script.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows]
"CurrentInstallFolder"="C:\\Program Files (x86)\\Windows Kits\\8.1\\"

This should fix it for any Windows 8.1 64-bit users, but if you have your Windows SDK installed in another directory, simply replace C:\Program Files (x86)\Windows Kits\8.1 with your respective directory. Here are a few places you can try:

  • C:\Program Files (x86)\Windows Kits
  • C:\Program Files (x86)\Microsoft SDKs\Windows
  • C:\Program Files (x86)\Microsoft\Microsoft SDKs\Windows

Note: Make sure to append the version as well to the end of the path; for example, 8.1 is at the end of my path. Basically, you need to get the full path to the Windows SDK and not just the folder containing the main folder(s) for the Windows SDK.

5
votes

As Parvez pointed, New C++ project, then "Install Windows XP support for C++"

enter image description here

4
votes

Installing Windows SDK v8.1 solved it for me.

3
votes

Try to invoke SetEnv.cmd manually in your command prompt:

call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86

OR

call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64
2
votes

For myself works this:

Check the value in "your".vcxproj <PlatformToolset>"some version"</PlatformToolset>

I know it is strange but:

I have installed VC2012 and VC2010 and I compile project from 2012 in 2010 with toolset "v110".

2
votes

I was also facing the same issue.

Installing Windows SDK v8.1 solved it for me.

https://msdn.microsoft.com/en-us/windows/desktop/bg162891.aspx

1
votes

I was getting the error mentioned below when I was trying to install oracle driver for nodejs using npm install oracledb. I have Windows 7.1 SP1 and I have installed Visual Studio 2015 community edition.

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.

Installing VC++ compiler as mentioned here resolved the issue for me. For reference here is the action to do.

You need to launch Visual studio, then do: file > new > project, in the window than opened, select "Model > Visual C++" and in the middle of the window you should see a button "install microsoft C++" or something like that, click on it and it will launch the install process for the C++ & Microsoft SDK. Once that's done it will work as expected !

1
votes

I had this same problem with VS2012. I had both 2013 and 2012 installed on my machine and experienced the issue after uninstalling VS2013 (which I was not using anymore due to expired license).

The Registry keys linked above did not help me. In my opinion, independently from your VS version, the safest way to address this is to locate the batch file VS uses to load those macros, which seems to be VCVarsQueryRegistry.bat in C:\Program Files (x86)\Microsoft Visual Studio [YOUR_VERSION].0\Common7\Tools.

Look for the variable VS tells it is not defined. You might then find a snippet like:

@set WindowsSdkDir=
@call :GetWindowsSdkDirHelper32 HKLM > nul 2>&1
@if errorlevel 1 call :GetWindowsSdkDirHelper32 HKCU > nul 2>&1
@if errorlevel 1 call :GetWindowsSdkDirHelper64 HKLM > nul 2>&1
@if errorlevel 1 call :GetWindowsSdkDirHelper64 HKCU > nul 2>&1
@exit /B 0

:GetWindowsSdkDirHelper32
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0" /v "InstallationFolder"') DO (
    @if "%%i"=="InstallationFolder" (
        @SET "WindowsSdkDir=%%k"
    )
)
@if "%WindowsSdkDir%"=="" exit /B 1
@exit /B 0

:GetWindowsSdkDirHelper64
@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0" /v "InstallationFolder"') DO (
    @if "%%i"=="InstallationFolder" (
        @SET "WindowsSdkDir=%%k"
    )
)

Which makes clear that WindowsSdkDir in a 64bit system is set by Registry value SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.0\InstallationFolder in either HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE depending on your configuration.

0
votes

Adding my observations of a similar problem reporting the same error....

If the required SDKs are installed, but the problem persists, try toggling the Platform Toolset under the project's General configuration properties. For example, I changed Visual Studio 2013 (v120) to Visual Studio 2015 (v140). After applying, I reverted the Platform Toolset back to Visual Studio 2013 (v120) which corrected the problem of the missing WindowsSDKDir setting.

On another workstation where the project works, VS2012 is installed. The new workstation without VS2012 complains about the missing WindowsSDKDir setting; although, the Platform Toolset parameter displays Visual Studio 2013 (v120)