Repository navigation
Quote left side of MSBuild condition expressions - #16325
Merged
Azat Mukhametshin (azat-msft) merged 1 commit intoJul 30, 2026
Merged
Azat Mukhametshin (azat-msft) merged 1 commit into
Azat Mukhametshin (azat-msft) merged 1 commit into
Conversation
Fixes rule B-2 findings from the MSBuild quality report: the left side of == was not single-quoted in Directory.Build.props (NetPrevious) and Directory.Build.targets (TestProject). Unquoted properties evaluate to an empty token when unset, which can produce a malformed condition. Fixes microsoft#16308 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bad0e1f8-5f21-4c49-b3cf-d086f856c491
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates MSBuild condition expressions to single-quote the left-hand property expansion in == comparisons, preventing malformed condition expressions when a property is unset (MSBuild quality rule B-2) while keeping semantics equivalent when the property is set.
Changes:
- Quote
$(TestProject)on the left side of==inDirectory.Build.targetstest-project gating condition. - Quote
$(NetPrevious)on the left side of==inDirectory.Build.propsframework selection fallback condition.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Directory.Build.targets | Quotes $(TestProject) in the <When> condition to avoid empty expansion producing malformed expressions when unset. |
| Directory.Build.props | Quotes $(NetPrevious) in the condition for defaulting NetPrevious to NetMinimum when the property is unset/empty. |
Azat Mukhametshin (azat-msft)
enabled auto-merge (squash)
July 30, 2026 12:53
YuliiaKovalova
approved these changes
Jul 30, 2026
Azat Mukhametshin (azat-msft)
merged commit Jul 30, 2026
f7d5f02
into
microsoft:main
20 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the two rule B-2 findings reported in #16308.
Directory.Build.props:<NetPrevious Condition=" $(NetPrevious) == '' ">→'$(NetPrevious)'Directory.Build.targets:<When Condition="$(TestProject) == 'true' AND ...">→'$(TestProject)'Unquoted properties on the left of
==expand to nothing when unset, which can yield a malformed condition expression. Quoting is the standard MSBuild pattern and is semantically equivalent when the property is set.Verified with a full
build.cmd -c Release— all projects including test projects build (exercising theTestProjectcondition). The only failure is a pre-existingVSSDK1025packaging error for an internal-only Cpp extension file, unrelated to this change.Fixes #16308