Skip to content

[release/17.0] Fix flaky ComputeRunArgumentsPopulatesRunPropertiesForSdkProject (MSBuild server fallback notice on stderr) - #22038

Closed
Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-39-pr21961from
mitchdenny-backport-17-0-40-pr21955
Closed

Mitch Denny (mitchdenny) wants to merge 1 commit into
mitchdenny-backport-17-0-39-pr21961from
mitchdenny-backport-17-0-40-pr21955

Conversation

@mitchdenny

Copy link
Copy Markdown
Member

Description

Backport of #21955 to release/17.0 (cherry-picked from bd8d7d0 with no modifications).

Layer 40 of 55 in the release/17.0 backport stack; stacked on #22037.

Backport recommendation: No — Test flake.

Validation: Stable patch IDs match (ae81520aa68a427c45d52ee6cd7d96ebfd3a5d07). Builds/tests not run for this unchanged cherry-pick.

Backport of #21955

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

…uild server fallback notice on stderr) (#21955)

## Description

**What failed.**
`DotNetCliRunnerTests.ComputeRunArgumentsPopulatesRunPropertiesForSdkProject`
failed on Windows after #21502 merged. One example is
[run
42237500020](https://github.com/microsoft/aspire/actions/runs/42237500020),
job `Cli (windows-latest)`, from a PR branch that already contains
#21502. The process exited 0 and every property was
correct, but stderr contained:
`MSBuild server unavailable: could not connect to the server within the
timeout window; the server may have failed to start. Falling back to an
in-process build.`

**Why.** The test spawns a raw `dotnet msbuild -restore
-getProperty:...` and asserts that stderr is empty. With SDK 11, `dotnet
msbuild` uses MSBuild server by default. A newly launched server gets 5
s to accept the client connection
(`NewServerConnectionTimeoutMilliseconds` in
[MSBuildClient.cs](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Client/MSBuildClient.cs)).
On loaded runners it misses that window, so MSBuild builds in-process
and [writes this notice to
stderr](https://github.com/dotnet/msbuild/blob/main/src/MSBuild/MSBuildClientApp.cs).

**Fix.** Set `DOTNET_CLI_USE_MSBUILD_SERVER=0` on the test's child
process, as `TemplateManifestTestEnvironment` and
`TemplateRestorePlanTests` already do for the same message. The
empty-stderr assertion is unchanged, so real warnings from the project
still fail the test. This is a test-only change; the product probe path
parses stdout and ignores this notice.

Fixes #21954

### Confidence

The repro uses the real test and induces a genuine slow server start. A
watcher pauses each newly launched `/nodemode:8` MSBuild server for 7 s
and then resumes it (Linux, SDK 11.0.100-rc.2.26504.105, the repo-local
SDK).

| | Real xUnit test | Raw `dotnet msbuild` command |
|---|---|---|
| Before (main) | **10/10 fail**, same message, same line
(`DotNetCliRunnerTests.cs:2754`) as CI | 10/10 fail |
| After (this PR) | **10/10 pass** | 10/10 pass |

All 93 tests in `DotNetCliRunnerTests` pass with the change, without the
harness. Main uncertainty: only one post-fix CI hit could be located and
confirmed with this signature. The tracker's second post-fix hit (11-07
01:06Z) could not be matched to a run, and its log may have expired.

**How we stop this recurring:** tests that spawn `dotnet msbuild` and
assert on its output must opt out of MSBuild server
(`DOTNET_CLI_USE_MSBUILD_SERVER=0`). SDK 11 now reports server fallback
on stderr.

## Failure stats (14d, attempt 1)

- **Test/signature:**
`Aspire.Cli.Tests.DotNet.DotNetCliRunnerTests.ComputeRunArgumentsPopulatesRunPropertiesForSdkProject`.
The post-fix signature is
`Assert.True(string.IsNullOrWhiteSpace(stderr))` failing on `MSBuild
server unavailable: ...`. Earlier hits were the `NU1900` audit warning
fixed by #21502.
- **Failures/runs:** 8/1175 (≈0.68%) per tracker #21600:
3 main, 5 PR. No PR-caused failures were identified to exclude. 2 of the
PR hits came after #21502, and the one I located is on a
branch 0 commits behind the fix, so it is genuine.
- **Rerun-pass count:** not available from the tracker data. The located
PR run was rerun (attempt 4).
- **Last hit:** 2026-11-07 01:06Z per tracker (run not located). Last
confirmed: 2026-11-06 14:57Z, [run
42237500020](https://github.com/microsoft/aspire/actions/runs/42237500020).
- **Still hitting main?** No main hit since #21502
merged (2026-11-04 23:54Z). Both post-fix hits were on PR branches.
- **Local:** before 10/10 fail, after 10/10 pass (see Confidence).
- **This PR's CI:** green on e0e40b6 ([CI run
42575543144](https://github.com/microsoft/aspire/actions/runs/42575543144)),
including `Cli (windows-latest)`, `Cli (ubuntu-latest)` and `Cli
(macos-latest)`.
- **Verdict: STRONG.** The CI signature is reproduced exactly and
deterministically, and the fix removes the mechanism that produces it.
The sample of post-fix hits is small.

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes (test-only fix)
  - [ ] No
- Did you add public API?
  - [ ] Yes
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
  - [x] No

**🤖 Posted by AspireAgent (AI Agent)**

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(cherry picked from commit bd8d7d0)
@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-40-pr21955 branch from b666a35 to 7aef2b0 Compare November 10, 2026 04:23
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-40-pr21955 branch from 7aef2b0 to b666a35 Compare November 10, 2026 04:25
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22038

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22038"

@mitchdenny
Mitch Denny (mitchdenny) marked this pull request as ready for review November 10, 2026 05:10
@mitchdenny

Copy link
Copy Markdown
Member Author

Approved for inclusion in release/17.0. Do not merge yet.

@github-actions

This comment has been minimized.

@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-40-pr21955 branch from 6b335d5 to b666a35 Compare November 10, 2026 06:29
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-40-pr21955 branch from b666a35 to 6b335d5 Compare November 10, 2026 07:50
@mitchdenny
Mitch Denny (mitchdenny) force-pushed the mitchdenny-backport-17-0-40-pr21955 branch from 6b335d5 to b666a35 Compare November 10, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants