Open KorkiFork opened 2 months ago
@KorkiFork We are trying to reproduce your issue, but have a problem finding “MSVC kit A” and “MSVC kit B”, could you provide us with a reproduction folder? This will help us a lot in reproducing and investigating the issue, thank you!
I attached the cmake-tools-kits.json file, please try using it.
(Sorry for closing and reopening issue, not sure how this comment system works, it is a bit strange).
Never mind I've reopened this issue, could you provide us with a project that can reproduce the issue? It's not just the cmake-tools-kits.json file, we can't reproduce the issue by adding the cmkae-tools-kits.json file to our project.
I already provide you a CMake project via a CMakeLists.txt in my original post (please check my first post again, below the kits definition, there is also a CMakeLists.txt file).
Hi @Yingzi1234, Thank you very much for the effort of recording the video.
I noticed that your cmake-tools.kits.json has errors (as you can see for example on lines 2 and 16, which are underlined with red markings). Because the cmake-tools.kits.json file has errors, the CMake Tools extension can't load it, and it will still display the old kits (kits that have been loaded the last time when the cmake-tools-kits.json file was valid).
The cmake-tools-kits.json I provided you starts and ends with square brackets "[" ... "]", on line 1 and 36, but yours starts and ends with curly brackets "{" ... "}". Could you please try correcting this? I just realized that in my initial post, I also added curly brackets by mistake in lines 1 and 36, I'm sorry for that. Those should be square brackets.
@Yingzi1234 Hi again.
I'm not sure why the kits are not recognized for you. Maybe you don't edit them in you user folder? Anyway. Here is the video that demonstrates that my VS Code and the CMake extensions does recognize them.
https://github.com/user-attachments/assets/6723b173-b78a-4620-b386-54a45d8825a3
Further, I realized that my example is not correct is some cases and I won't configure the project at all. I had to adapt it in the following way:
After I made those adaptations, I recorder the example of the PATH variable having different values with kit A and B.
https://github.com/user-attachments/assets/0a9e9862-160e-460b-85a4-b77502bee448
Hi @KorkiFork , thank you very much for your reply, the reason for the failure to reproduce may be due to the name of the file. We have now been able to reproduce your issue on the latest CMake tool version v1.20.10(pre-release). You can get the detailed steps to reproduce it below. @gcampbell-msft We were able to reproduce this issue on the latest version, and we have added the bug label to this issue, you can get the exact reproduction steps and reproduction information from below, thanks!
ENV: C/C++: V1.21.6 CMake tools: v1.20.10(pre-release) VSCode: 1.93.1
Repro steps:
Actual result:
MSVC kit A
correctly reflects the impact of environment Setup Script, while MSVC kit B
does not
Output log:
MSVC kit A:
[cmake] -- PATH variable value is: C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33721\bin\HostX86\x86;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\VC\VCPackages;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\;C:\Program Files\Microsoft Visual Studio\2022\Preview\Team Tools\DiagnosticsHub\Collector;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\Extensions\Microsoft\CodeCoverage.Console;C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\\x86;C:\Program Files (x86)\Windows Kits\10\bin\\x86;C:\Program Files\Microsoft Visual Studio\2022\Preview\\MSBuild\Current\Bin\amd64;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\Tools\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\msys64\mingw64\bin;C:\ProgramData\chocolatey;C:\msys64\ucrt64\bin;C:\msys64\mingw64\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.exe;C:\Users\v-cathyzhang\Downloads\ninja-win\ninja.exe;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Users\v-cathyzhang\AppData\Local\Microsoft\WindowsApps;C:\Users\v-cathyzhang\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\v-cathyzhang\.dotnet\tools;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\VC\Linux\bin\ConnectionManagerExe;C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\vcpkg
MSVC kit B:
[cmake] -- PATH variable value is: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.40.33721/bin/HostX86/x86;C:/Program Files/Microsoft Visual Studio/2022/Preview\Common7\IDE\VC\VCPackages;C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/CommonExtensions/Microsoft/TestWindow;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:/Program Files/Microsoft Visual Studio/2022/Preview/MSBuild/Current/bin/Roslyn;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\;C:/Program Files/Microsoft Visual Studio/2022/Preview/Team Tools/DiagnosticsHub/Collector;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\Extensions\Microsoft\CodeCoverage.Console;C:/Program Files (x86)/Windows Kits/10/bin/10.0.22621.0\\x86;C:/Program Files (x86)/Windows Kits/10/bin\\x86;C:\Program Files\Microsoft Visual Studio\2022\Preview\\MSBuild\Current\Bin\amd64;C:/Windows/Microsoft.NET/Framework/v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\;C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/Tools/;C:\Windows\system32;C:/Windows;C:\Windows\System32\Wbem;C:/Windows/System32/WindowsPowerShell/v1.0/;C:\Windows\System32\OpenSSH\;C:/msys64/mingw64/bin;C:\ProgramData\chocolatey;C:/msys64/ucrt64/bin;C:\msys64\mingw64\bin;C:/ProgramData/chocolatey/bin;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe;C:\Users\v-cathyzhang\Downloads\ninja-win\ninja.exe;C:/Program Files/Microsoft SQL Server/130/Tools/Binn/;C:\Program Files\Git\cmd;C:/Users/v-cathyzhang/AppData/Local/Microsoft/WindowsApps;C:\Users\v-cathyzhang\AppData\Local\Programs\Microsoft VS Code\bin;C:/Users/v-cathyzhang/.dotnet/tools;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja;C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\VC\Linux\bin\ConnectionManagerExe;C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/vcpkg
@Yingzi1234 Thank you very much for the support and patience.
I will be glad to see this bug being resolved in the future.
Brief Issue Summary
Tested with: CMake Tools v1.20.10 (pre-release). All prior versions, released within the last year or two, had the same issue.
In the cmake-tools-kits file, if a kit has an environmentSetupScript which modifies the system PATH, and if in the same kit the environmentVariables object sets the variable PATH to have the value ${env.PATH}, the resulting PATH value will equal the PATH value prior to calling the environmentSetupScript. TL;DR environmentSetupScript does not effect the value returned by ${env.PATH}.
E.g. I used MSVC build tools 2017 v14.16, but any other MSVC build tools version can be taken (2019, 2022 etc.) and installed it on the default location. In the kit description, I explicitly set CMAKE_MAKE_PROGRAM to the path of nmake.exe in order to simplify this example (please ignore why I had to do this, just take it as it is).
If any of the below two kits is used with the example CMakeLists.txt I provided below, during the project's build tree configuration, a STATUS message will be printed, which will contain the value of the system PATH variable. If the "MSVC kit A" is used, the printed PATH variable will contain directories that have been added by the environmentSetupScript. If the "MSVC kit B" is used, the printed PATH variable will NOT contain directories that should have been added by the environmentSetupScript, but it will contain the system PATH value prior to calling the environmentSetupScript.
cmake-tools-kits.json
CMakeLists.txt
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response