Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2015 / MsBuild / vsvars32.bat : Cannot determine the location of the VS installation

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

like image 242
Laurent BERTHET Avatar asked Jul 28 '15 15:07

Laurent BERTHET


3 Answers

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.

like image 183
Jagd Avatar answered Nov 15 '22 11:11

Jagd


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.

like image 22
Brian Francis Avatar answered Nov 15 '22 10:11

Brian Francis


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.

like image 45
Robson Avatar answered Nov 15 '22 12:11

Robson