Closed sarunint closed 2 days ago
any updates on this?
I just found a workaround for this, as I am facing the same problem:
Create a batch file that sets up your build environment. I called it env.bat
and for me it looks like this:
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 -vcvars_ver=14.16
Then setup a custom CMake-Kit by editing your %localappdata%\CMakeTools\cmake-tools-kits.json
(open using Command Palette: > CMake: Edit User-Local Cmake Kits
) and add your own kit. You can copy an existing Kit, but I had to remove some Visual Studio specifics ("visualStudio"
and "visualStudioArchitecture"
) to get it working without errors. As I am trying to use ninja for building, I changed the generator to Ninja
. If you want to stay with MSBuild, you probably should keep the generator from the kit you copied. The "keep": true
in there makes the new entry persist in case you scan for kits again. So here is mine:
[
{
"name": "Visual Studio Professional 2017 Release - x86_amd64",
"environmentSetupScript": "path\\to\\your\\env.bat",
"keep": true,
"preferredGenerator": {
"name": "Ninja"
}
}
]
Then save the file. I immediately got some errors about json parsing failing:
[kit] Failed to parse cmake-tools-kits.json:
SyntaxError: Unexpected EOF at line 1 column 2 of the JSON5 data. Still to read: ""
at error (c:\Users\<snip>\.vscode-server\extensions\ms-vscode.cmake-tools-1.6.0\dist\main.js:20167:25)
at word (c:\Users\<snip>\.vscode-server\extensions\ms-vscode.cmake-tools-1.6.0\dist\main.js:20504:13)
at value (c:\Users\<snip>\.vscode-server\extensions\ms-vscode.cmake-tools-1.6.0\dist\main.js:20604:56)
at Object.parse (c:\Users\<snip>\.vscode-server\extensions\ms-vscode.cmake-tools-1.6.0\dist\main.js:20619:18)
at Object.readKitsFile (c:\Users\<snip>\.vscode-server\extensions\ms-vscode.cmake-tools-1.6.0\dist\main.js:9318:26)
at async Function.readUserKits (c:\Users\<snip>\.vscode-server\extensions\ms-vscode.cmake-tools-1.6.0\dist\main.js:15430:27)
I ignored those and reloaded/restarted VSCode instead. Afterwards there weren't any json parsing errors any more.
Finally, select the newly added kit (Command Palette: > CMake: Select a Kit
). Now I have the correct environment when building.
I hope it helps.
Been having the same issue and output like you with msvc2015 installed from a VS 2017 setup on Windows 10, with other IDEs as well. What I've found then is that Windows 10 comes with some sort of .Net Framework which also has a MSBuild by itself which is found in path before the one from MSVC, and the only working solution was to prepend to PATH the correct MSBuild, e.g. in my case %programfiles(x86)%/Microsoft Visual Studio/2017/Proffesional/MSBuild/15.0/Bin
@sarunint @pborsutzki @danimihalca Is this issue still remaining?
@gcampbell-msft fortunately my team and I do not rely on Visual Studio 2015 toolchains any more, so I can't tell. Though we currently do not have problems using Visual Studio 2022 toolchains with the extension.
@sarunint @pborsutzki @danimihalca Is this issue still remaining?
I'm not using that environment anymore, therefore I cannot reproduce it, nor is it relevant for me as a consumer.
Brief Issue Summary
I've installed VS2015 Build Tools via the latest version of Visual Studio Installer.
It is known that VS2015 Build Tools that is installed with newer VS installer will not have its shortcuts working correctly (including it's
vcvarsall.bat
).The correct way to load up VS2015 Build Tools into a command prompt is to load using VS2017/9's
vcvarsall.bat
with argumentvcvars_ver
.Expected:
Apparent Behavior:
CMake Tools Log
The cmake log is identical to what happens when I use VS2015's
vcvarsall.bat
.Developer Tools Log
I only provided the relevant bit here.
This shows that the CMake Tools is using the
vcvarsall.bat
that came with VS2015 Build Tools (C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
) instead of the modernvcvarsall.bat
(In my case, it is atC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat
).Platform and Versions
Other Notes/Information
I've narrowed down the code that should be change. I think.
https://github.com/microsoft/vscode-cmake-tools/blob/d53c266c9b0bb43a2b1ca3d68c04de49fe5fc717/src/kit.ts#L672-L676