6
votes

I use a batch to build my solution. It work fine with Visual Studio 2013. But with Visual Studio 2015 this error occurs :

ERROR: Cannot determine the location of the VS installation

Batch for VS2013

call "%VS120COMNTOOLS%vsvars32.bat"
msbuild solution.sln /t:rebuild /p:Configuration=Release /p:Platform="Any CPU"

Work fine.

Batch for VS2015

call "%VS140COMNTOOLS%vsvars32.bat"
msbuild solution.sln /t:rebuild /p:Configuration=Release /p:Platform="Any CPU"

ERROR: Cannot determine the location of the VS installation.


The environment variable VS140COMNTOOLS is defined to

C:\Program Files\Microsoft Visual Studio 14.0\Common7\Tools

It's not the good path on my OS (Windows 8.1 64 bits). So I set VS140COMNTOOLS to

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools

But error message still the same.

If anyone has ideas...
Thanks in advance :)

EDIT

I have found this temporary workaround with mklink (and add compatibility for older Visual Studio) :

IF NOT "%VS140COMNTOOLS%" == "" (  
    IF NOT EXIST "%VS140COMNTOOLS%" (  
        mklink /J "%VS140COMNTOOLS%" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools"  
    )  
    call "%VS140COMNTOOLS%vsvars32.bat"  
    echo Visual Studio 2015...
) ELSE (  
    IF NOT "%VS120COMNTOOLS%" == "" (  
        call "%VS120COMNTOOLS%vsvars32.bat"  
       echo Visual Studio 2013...
    ) ELSE (  
        call "%VS110COMNTOOLS%vsvars32.bat"  
        echo Visual Studio 2012...
    )  
)   

... and after call msbuild.

Have you a best solution ?...

4
This is a broken registry problem, your machine appears to be missing the required registry entry in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7, 14.0 value. Or the 32-bit version in Wow6432Node, depends on the flavor of cmd.exe. Very unhealthy of course, feel free to panic.Hans Passant
Thanks a lot Hans. In my registry I have HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7=C:\Program Files\Microsoft Visual Studio 14.0\ and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7 = C:\Program Files (x86)\Microsoft Visual Studio 14.0\. It appears to be correct.Laurent BERTHET
Hmm, that limits the number of possible explanations. You'll need to find out why vcvarsqueryregistry.bat in the same directory fails to get its job done. A massive environment that exceeds the max size is all I can think of.Hans Passant

4 Answers

8
votes

For me, the path in HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7 was missing (x86).

It can be solved with this .reg file:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7]
"14.0"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"

Thank you for you hint.

4
votes

I recently had the same issue. Problem was an overly long PATH, resulting in the C:\Windows\System32\reg.exe command not being found when called in the batch file. I removed what I could from my PATH and this corrected the problem.

2
votes

I had a similar problem with VS 2013 and %VS110COMNTOOLS%... I tried loads of stuff that I found over the internet but none worked, also the most common solution that I found online was that C:\windows\system32 was missing from the PATH enviroment variable, but on my machine all the variables were correct and pointing to the right directories.

I had a windows 10 image with vs2017 installed and no other visual studios previously installed, so I restored that image, then proceeded to install VS2013, then I installed VS2010 and then finally installed VS2012.

After doing this the builds went fine and the error disappeared... I guess that installing VS2012 as the last one fixed the problem concerning the VS110COMNTOOLS variable, even tho I tried to reinstall all the visual studios before rolling back to the windows 10 image I had.

I hope you can do something similar on your machine, try to restore your system to a point before the visual studio installations and then install the visual studios you need leaving the VS2015 as the last one.

0
votes

In my case the problem was that registry editing was disabled on my PC entirely, by my system administrator.

This resulted in the command line command reg being inoperable, and that leads to the reported error.

The solution was to get registry access enabled.

Note - this also caused regedit to be disabled so the manual fix noted in another answer was not workable for me.