microsoft / microsoft/vscode-cmake-tools
[Bug] build failed after Visual Studio 2022 update
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
After today's update of Visual Studio 2022, VS Code with cmake fails to build a HelloWord.
### CMake Tools Diagnostics
```shell
{
"os": "win32",
"vscodeVersion": "1.134.0",
"cmtVersion": "1.23.52",
"configurations": [
{
"folder": "c:\\work\\helloword",
"cmakeVersion": "4.4.2",
"configured": true,
"generator": "Visual Studio 17 2022",
"usesPresets": false,
"compilers": {}
}
],
"cpptoolsIntegration": {
"isReady": false,
"hasCodeModel": false,
"activeBuildType": "",
"buildTypesSeen": [],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 0,
"executablesCount": 0,
"librariesCount": 0,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
}
```
### Debug Log
```shell
[main] Configuring project: helloword
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S C:/work/helloword -B c:/work/helloword/build -G "Visual Studio 17 2022" -T host=x86 -A x64
[main] Changes were detected in CMakeLists.txt but we could not reconfigure the project because another operation is already in progress.
[main] Configuring project: helloword
[cmake] The --no-warn-unused-cli option is deprecated. Use -Wno-unused-cli instead.
[main] Failed to prepare executable target with name "undefined"
[cmake] -- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.26200.
[cmake] CMake Error at CMakeLists.txt:2 (project):
[cmake] Failed to run MSBuild command:
[cmake]
[cmake] C:/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/Bin/amd64/MSBuild.exe
[cmake]
[cmake] to get the value of VCTargetsPath:
[cmake]
[cmake] MSBuild version 17.14.51+25f168cee for .NET Framework
[cmake] Build started 21/08/2026 9:49:18.
[cmake]
[cmake] Project "C:\work\helloword\build\CMakeFiles\4.4.2\VCTargetsPath.vcxproj" on node 1 (default targets).
[cmake] PrepareForBuild:
[cmake] Creating directory "VCTargetsPath\x64\Debug\".
[cmake] Structured output is enabled. The formatting of compiler diagnostics will reflect the error hierarchy. See https://aka.ms/cpp/structured-output for more details.
[cmake] Creating directory "C:\work\helloword\build\CMakeFiles\4.4.2\x64\Debug\".
[cmake] Creating directory "VCTargetsPath\x64\Debug\VCTargetsPath.tlog\".
[cmake] InitializeBuildStatus:
[cmake] Creating "VCTargetsPath\x64\Debug\VCTargetsPath.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
[cmake] Touching "VCTargetsPath\x64\Debug\VCTargetsPath.tlog\unsuccessfulbuild".
[cmake] PostBuildEvent:
[cmake] echo VCTargetsPath=C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\
[cmake] :VCEnd
[cmake] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: The command "echo VCTargetsPath=C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\ [C:\work\helloword\build\CMakeFiles\4.4.2\VCTargetsPath.vcxproj]
[cmake] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :VCEnd" exited with code -1073741502. [C:\work\helloword\build\CMakeFiles\4.4.2\VCTargetsPath.vcxproj]
[cmake] Done Building Project "C:\work\helloword\build\CMakeFiles\4.4.2\VCTargetsPath.vcxproj" (default targets) -- FAILED.
[cmake]
[cmake] Build FAILED.
[cmake]
[cmake] "C:\work\helloword\build\CMakeFiles\4.4.2\VCTargetsPath.vcxproj" (default target) (1) ->
[cmake] (PostBuildEvent target) ->
[cmake] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: The command "echo VCTargetsPath=C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\ [C:\work\helloword\build\CMakeFiles\4.4.2\VCTargetsPath.vcxproj]
[cmake] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :VCEnd" exited with code -1073741502. [C:\work\helloword\build\CMakeFiles\4.4.2\VCTargetsPath.vcxproj]
[cmake]
[cmake] 0 Warning(s)
[cmake] 1 Error(s)
[cmake]
[cmake] Time Elapsed 00:00:01.09
[cmake]
[cmake]
[cmake] Exit code: 1
[cmake]
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S C:/work/helloword -B c:/work/helloword/build -G "Visual Studio 17 2022" -T host=x86 -A x64 exited with code: 1
```
### Additional Information
CMakeLists.txt:
```
cmake_minimum_required(VERSION 4.4)
project(helloword LANGUAGES C CXX)
add_executable(helloword main.cpp)
set_target_properties(helloword PROPERTIES LINKER_LANGUAGE CXX)`
```
Writing the command in terminal
```
"C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S C:/work/helloword -B c:/work/helloword/build -G "Visual Studio 17 2022" -T host=x86 -A x64
At line:1 char:40
+ "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMAND ...
+ ~~~~~~~
Unexpected token '-DCMAKE' in expression or statement.
At line:1 char:47
+ ... Make\bin\cmake.EXE" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-wa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '_EXPORT_COMPILE_COMMANDS:BOOL=TRUE' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
```
Also, I notice that there is postprocess command:
echo VCTargetsPath=C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\ ...
But the path is not between "" and spaces in the directory might also cause to fail.
Switching to the kit Mingw, compiles without issues.
Contributor guide
Research direction
Reproduce the failure with the supplied CMakeLists.txt and Visual Studio 17 2022 command, then inspect the generated build/CMakeFiles/4.4.2/VCTargetsPath.vcxproj and the MSBuild post-build command shown in the log. Done means the Visual Studio kit configures and builds the HelloWorld project successfully in VS Code, while the existing MinGW configuration continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, vscode
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100