Windows SDK registry variable not found

后端 未结 11 1013
闹比i
闹比i 2020-12-14 01:42

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.targe

11条回答
  •  天涯浪人
    2020-12-14 02:06

    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.

提交回复
热议问题