Skip to content

Fix Analyzers build race condition and sync unofficial pipeline#15183

Closed
joperezr wants to merge 3 commits intomicrosoft:release/13.2from
joperezr:joperezr-TestingFixBuild
Closed

Fix Analyzers build race condition and sync unofficial pipeline#15183
joperezr wants to merge 3 commits intomicrosoft:release/13.2from
joperezr:joperezr-TestingFixBuild

Conversation

@joperezr
Copy link
Copy Markdown
Member

@joperezr joperezr commented Mar 12, 2026

Summary

This PR fixes the intermittent MSB3026/CS2012 file-locking errors on Aspire.Hosting.Analyzers.dll that have been causing the dotnet-aspire official pipeline to fail on the release/13.2 branch.

Root Cause

The Aspire.Hosting.AppHost.csproj had a direct ProjectReference to Aspire.Hosting.Analyzers without SetTargetFramework or GlobalPropertiesToRemove. Since src/Directory.Build.targets also injects an analyzer reference with those attributes into all Aspire.Hosting.* projects, MSBuild saw two different global-property configurations and created two parallel build nodes targeting the same output path. When both nodes tried to write Aspire.Hosting.Analyzers.dll simultaneously, Pdb2Pdb would hold a file lock causing the second node to fail.

Changes

  1. src/Aspire.Hosting.AppHost/Aspire.Hosting.AppHost.csproj: Added SetTargetFramework and GlobalPropertiesToRemove to the direct ProjectReference, and Properties/RemoveProperties to the MSBuild task call — aligning them with the injected reference from Directory.Build.targets so MSBuild deduplicates into a single node.

  2. eng/pipelines/azure-pipelines-unofficial.yml: Synced with the official pipeline:

    • Updated VM image from windows.vs2022preview.amd64 (no longer exists) to windows.vs2026preview.scout.amd64
    • Added Node.js, yarn, and vsce install steps that the official pipeline already has

Validation

  • Reproduced the race locally with the CI build command, confirmed it fails consistently before the fix
  • Ran 5 clean build iterations after the fix — 0 file-locking errors across all 5 runs
  • Queued an unofficial pipeline run to validate end-to-end

@radical This is an attempt to fix the race conditions we've been seeing in the dotnet-aspire official builds on release/13.2. The Analyzers DLL file-locking error has been hitting 3 out of the last 5 builds.

joperezr and others added 3 commits March 12, 2026 10:38
The Aspire.Hosting.AppHost.csproj had a direct ProjectReference to
Aspire.Hosting.Analyzers without SetTargetFramework or
GlobalPropertiesToRemove. Since Directory.Build.targets also injects
an analyzer reference WITH those attributes, MSBuild saw two different
global-property sets and created two parallel build nodes for the same
output path, causing intermittent Pdb2Pdb file-locking errors
(MSB3026/CS2012) on Windows CI.

This aligns the direct reference and MSBuild task call with the
injected one so MSBuild deduplicates them into a single node.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…M image

The unofficial pipeline was still using the now-removed
windows.vs2022preview.amd64 image, causing the build stage to be
skipped. Updated to match the official pipeline's image.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The unofficial pipeline was missing the Node.js, yarn, and vsce
installation steps that the official pipeline has before calling the
BuildAndTest template. Since BuildAndTest uses /p:BuildExtension=true,
the VS Code extension build requires these tools.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 12, 2026 18:49
@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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15183

Or

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses intermittent MSBuild file-locking failures involving Aspire.Hosting.Analyzers.dll by aligning the Aspire.Hosting.AppHost direct analyzer ProjectReference (and an MSBuild invocation) with the repo-wide injected analyzer reference, and it updates the unofficial Azure Pipelines definition to match current official pipeline prerequisites.

Changes:

  • Align Aspire.Hosting.AppHost’s direct ProjectReference to Aspire.Hosting.Analyzers with SetTargetFramework and GlobalPropertiesToRemove to avoid parallel builds targeting the same output.
  • Update the IncludeAnalyzerInPackage MSBuild call to use consistent Properties/RemoveProperties for GetTargetPath.
  • Sync unofficial pipeline VM image and add Node/yarn/vsce setup steps to match the official pipeline.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Aspire.Hosting.AppHost/Aspire.Hosting.AppHost.csproj Aligns analyzer project reference/MSBuild invocation properties to prevent duplicate build nodes and file-lock races.
eng/pipelines/azure-pipelines-unofficial.yml Updates the Windows image and adds Node/yarn/vsce setup steps to keep the unofficial pipeline consistent with the official one.

You can also share your feedback on Copilot code review. Take the survey.

@eerhardt
Copy link
Copy Markdown
Member

@joperezr - I'm fixing this in #15176

@joperezr
Copy link
Copy Markdown
Member Author

@joperezr - I'm fixing this in #15176

Didn't realize you were working on this. Closing it as a dupe.

@joperezr joperezr closed this Mar 12, 2026
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 12, 2026
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.

3 participants