MSB4211 warning: "GetTargetPathDependsOn" is set after being consumed — triggered by Microsoft.CppBuild.targets
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 141
Description
I'm encountering the following warning during C++ project builds in Visual Studio 2022 (v17.0, toolset v143):
`warning MSB4211: The property "GetTargetPathDependsOn" is being set to a value for the first time, but it was already consumed at "Microsoft.Common.CurrentVersion.targets".`
After inspecting the preprocessed MSBuild output (msbuild /pp), I confirmed that:
- GetTargetPathDependsOn is used in Microsoft.Common.CurrentVersion.targets
- It is set later in Microsoft.CppBuild.targets
This appears to be a sequencing issue in the order of imports or property evaluation.
🔍 Environment:
- Visual Studio 2022 Professional
- MSBuild v17.0
- C++ project (.vcxproj)
- PlatformToolset: v143
❓ Expected behavior: No warning should be emitted if the property is used and set in a consistent and expected order by the MSBuild system itself.
✅ Workaround: Suppressing the warning via:
`
MSB4211
`
But ideally, this should be resolved in the targets themselves.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.