Add --max-parallel-count flag to control MSBuild and Docker build parallelism during deployment#4518
Draft
Add --max-parallel-count flag to control MSBuild and Docker build parallelism during deployment#4518
Conversation
Co-authored-by: cdhanna <3848374+cdhanna@users.noreply.github.com>
Co-authored-by: cdhanna <3848374+cdhanna@users.noreply.github.com>
Co-authored-by: cdhanna <3848374+cdhanna@users.noreply.github.com>
Co-authored-by: cdhanna <3848374+cdhanna@users.noreply.github.com>
Co-authored-by: cdhanna <3848374+cdhanna@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix security issues in ticket 4405
Add --max-parallel-count flag to throttle concurrent Docker builds
Feb 17, 2026
Co-authored-by: cdhanna <3848374+cdhanna@users.noreply.github.com>
Co-authored-by: cdhanna <3848374+cdhanna@users.noreply.github.com>
Co-authored-by: cdhanna <3848374+cdhanna@users.noreply.github.com>
Copilot
AI
changed the title
Add --max-parallel-count flag to throttle concurrent Docker builds
Add --max-parallel-count flag to control MSBuild parallelism during deployment
Feb 17, 2026
cdhanna
requested changes
Feb 17, 2026
Collaborator
cdhanna
left a comment
There was a problem hiding this comment.
- add tests that use the existing standard
- I was wrong before, we also need to limit the docker build as well. We can re-use the same flag, but regardless of sequential builds, it should make sure only so many docker builds are allowed to trigger at once. Ideally, it would emit the progress report for all them as zero, but then limit them to only run given the max parallel option.
| $"--verbosity minimal " + | ||
| $"--no-self-contained {runtimeArg} " + | ||
| $"--configuration Release " + | ||
| $"-m:{maxParallelCount} " + |
Collaborator
There was a problem hiding this comment.
where did this -m flag come from? I don't see that in the docs. Check env variables as well.
Author
There was a problem hiding this comment.
The -m flag is the short form of -maxCpuCount in MSBuild. From dotnet msbuild --help:
-maxCpuCount[:n] Specifies the maximum number of concurrent processes to
build with. (Short form: -m[:n])
I've added documentation comments in the code (commit ac492f4) explaining this.
Co-authored-by: cdhanna <3848374+cdhanna@users.noreply.github.com>
Author
Done in commit ac492f4:
The throttling now works at both levels: MSBuild compilation parallelism and Docker build parallelism. |
Copilot
AI
changed the title
Add --max-parallel-count flag to control MSBuild parallelism during deployment
Add --max-parallel-count flag to control MSBuild and Docker build parallelism during deployment
Feb 17, 2026
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.
Ticket
#4405
Brief Description
Deploying many services causes excessive RAM consumption. Root cause: MSBuild runs unbounded parallel project builds during solution compilation, and Docker builds run in parallel without limits. Added
--max-parallel-countflag (default: 8) that controls parallelism at two levels: passes-m:{count}to MSBuild to limit concurrent build nodes, and throttles concurrent Docker image builds.Changes
maxParallelCountparameter, passes-m:{count}todotnet publishwith documentation explaining the flagmaxParallelCountfrom command args toBuildSolutionCommand.Build()maxParallelCountregardless of sequential build flag--max-parallel-countflag tobeam deploy planandbeam deploy releaseMaxParallelCountTests.cswith 3 NUnit tests following existing test standardsunityenginestubs.addressables/binand/obj(lowercase variant)Usage
Limits both MSBuild to 5 parallel compilation nodes and Docker builds to 5 concurrent operations, reducing peak memory usage proportionally.
Implementation Details
The
-mflag is the short form of-maxCpuCountin MSBuild (seedotnet msbuild --help). The throttling mechanism usesTask.WhenAnyto wait for completion when concurrent limits are reached, ensuring smooth progress reporting while preventing memory exhaustion.Checklist
Notes
The implementation now controls parallelism at two critical points:
Both contribute significantly to memory usage when deploying many services.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.