Add MAUI build queue to serialize platform builds#15958
Open
jfversluis wants to merge 1 commit intomicrosoft:mainfrom
Open
Add MAUI build queue to serialize platform builds#15958jfversluis wants to merge 1 commit intomicrosoft:mainfrom
jfversluis wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15958Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15958" |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces build-queue serialization for .NET MAUI platform resources that share the same project file, preventing concurrent MSBuild executions that can intermittently fail due to file locking and XamlC resolution issues.
Changes:
- Added a per-project build queue (semaphore) and lifecycle subscriber that runs a pre-build step and shows Queued/Building dashboard states.
- Added a
ProjectLaunchArgsOverrideAnnotationand DCP support to override defaultdotnet runinvocation (e.g., todotnet build /t:Runfor MAUI). - Added extensive unit tests plus small updates to the MAUI playground and package/test warning suppressions.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Maui.Tests/MauiBuildQueueTests.cs | Adds unit tests for queueing/serialization, cancellation, restart behavior, and related edge cases. |
| tests/Aspire.Hosting.Maui.Tests/Aspire.Hosting.Maui.Tests.csproj | Suppresses ASPIREMAUI001 warning for the test project. |
| src/Aspire.Hosting/Dcp/DcpExecutor.cs | Adds support for overriding the base dotnet command args via annotation. |
| src/Aspire.Hosting/ApplicationModel/ProjectLaunchArgsOverrideAnnotation.cs | New annotation type used to override DCP-generated project launch args. |
| src/Aspire.Hosting.Maui/README.md | Documents the MAUI build queue behavior and architecture. |
| src/Aspire.Hosting.Maui/MauiProjectResourceExtensions.cs | Eagerly adds the per-project build queue annotation during AddMauiProject. |
| src/Aspire.Hosting.Maui/MauiPlatformHelper.cs | Configures MAUI platform resources to use launch-args override and adds build metadata annotation. |
| src/Aspire.Hosting.Maui/MauiHostingExtensions.cs | Registers the new MAUI build-queue event subscriber. |
| src/Aspire.Hosting.Maui/Lifecycle/MauiBuildQueueEventSubscriber.cs | Implements queued/building states, pre-build subprocess, cancellation, and post-build semaphore hold. |
| src/Aspire.Hosting.Maui/Aspire.Hosting.Maui.csproj | Suppresses ASPIREMAUI001 warning for the MAUI hosting package. |
| src/Aspire.Hosting.Maui/Annotations/MauiBuildQueueAnnotation.cs | Adds per-project semaphore and cancellation tracking. |
| src/Aspire.Hosting.Maui/Annotations/MauiBuildInfoAnnotation.cs | Adds per-resource build metadata used by the build-queue subscriber. |
| playground/AspireWithMaui/AspireWithMaui.MauiClient/MauiProgram.cs | Updates service base address scheme to https+http:// for HTTP fallback. |
| playground/AspireWithMaui/AspireWithMaui.MauiClient/AspireWithMaui.MauiClient.csproj | Updates several package references to stable versions. |
src/Aspire.Hosting.Maui/Lifecycle/MauiBuildQueueEventSubscriber.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting/ApplicationModel/ProjectLaunchArgsOverrideAnnotation.cs
Outdated
Show resolved
Hide resolved
f9c78be to
55fbab8
Compare
Adds build queue serialization for MAUI platform resources (Android, iOS, Mac Catalyst, Windows) that share the same project file. MSBuild cannot handle concurrent builds of the same project, causing intermittent file locking and XamlC assembly resolution failures. Key changes: - MauiBuildQueueEventSubscriber: per-project SemaphoreSlim(1,1) serializes dotnet build commands with Queued/Building dashboard states - ProjectLaunchArgsOverrideAnnotation: overrides DCP dotnet run with dotnet build /t:Run for MAUI device deployment - Stop-while-queued support with queue-aware stop command replacement - Post-build semaphore hold until DCP launch reaches stable state - 94 unit tests covering serialization, cancellation, timeouts, restart Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
55fbab8 to
c589809
Compare
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.
Summary
Adds build queue serialization for MAUI platform resources (Android, iOS, Mac Catalyst, Windows) that share the same project file. MSBuild cannot handle concurrent builds of the same project, causing intermittent file locking and XamlC assembly resolution failures. This PR serializes builds per-project using a semaphore.
Key Changes
Build Queue (
MauiBuildQueueEventSubscriber)BeforeResourceStartedEventfor MAUI platform resourcesSemaphoreSlim(1,1)to serializedotnet buildcommandsdotnet buildas a subprocess with output piped to the resource loggerDCP Launch Override (
ProjectLaunchArgsOverrideAnnotation)[Experimental("ASPIREMAUI001")]annotation overrides DCP defaultdotnet runwithdotnet build /t:Runbuild /t:Runbecausedotnet rundoes not support the Run target needed for device deployment--configurationautomaticallyStop-While-Queued Support
Post-Build Semaphore Hold
dotnet build /t:Runreaches a stable stateWatchAsyncon resource restartReview feedback addressed (from #14945)
Assembly.GetEntryAssembly()configuration reading (davidfowl)IDisposablefromMauiBuildQueueAnnotation(joperezr)IOExceptioncatch for broken pipe inPipeOutputAsyncKnownResourceStatesconstants instead of string literalsProjectLaunchArgsOverrideAnnotationwith[Experimental("ASPIREMAUI001")]ReleaseSemaphoreSafely()helper to guard againstObjectDisposedExceptionTask.Delaywith deterministicWaitForBuildStartedAsyncsignals in testsTesting
Files Changed
src/Aspire.Hosting.Maui/Lifecycle/MauiBuildQueueEventSubscriber.cs- Core queue logicsrc/Aspire.Hosting.Maui/Annotations/MauiBuildQueueAnnotation.cs- Per-project queue statesrc/Aspire.Hosting.Maui/Annotations/MauiBuildInfoAnnotation.cs- Build metadata per resourcesrc/Aspire.Hosting/ApplicationModel/ProjectLaunchArgsOverrideAnnotation.cs- DCP launch overridesrc/Aspire.Hosting/Dcp/ExecutableCreator.cs- Reads override annotationtests/Aspire.Hosting.Maui.Tests/MauiBuildQueueTests.cs- 94 tests