-
Notifications
You must be signed in to change notification settings - Fork 651
Inject DOTNET_CLI_USE_MSBUILD_SERVER env var for apphost builds and runs, using configuration for value #9946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@copilot try again |
@copilot try again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot wasn't able to review any files in this pull request.
@copilot can you get started on this PR. |
…and runs Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
Tested this out in a devcontainer and it looks like the server is starting (based on what the docs say). Unit tests seem to cover the edge cases. |
@baronfel where should we be seeing performance improvements? |
The main benefit today is saving the ~1-1.5s MSBuild entry node startup time. Thats not always needed today but when we AOT the dotnet CLI that'll become critical because we can't host the MSBuild central node in the dotnet CLI process anymore. And on top of that we'll be hosting the MSBuild eval cache off of that server node as well, so you'll be well positioned to just immediately get that when it lands post-10. |
We may as well merge this then ... its ready to go. |
Fixes #9945
This PR implements the enhancement to the Aspire CLI to always set the
DOTNET_CLI_USE_MSBUILD_SERVER
environment variable for all dotnet build and dotnet run (when noBuild == false) calls for apphost projects.Changes Made
Core Implementation
DotNetCliRunner
to acceptIConfiguration
dependency via constructorGetMsBuildServerValue()
helper method that reads fromconfiguration["DOTNET_CLI_USE_MSBUILD_SERVER"]
with default value of"true"
BuildAsync()
to always inject the environment variable before callingExecuteAsync
RunAsync()
to inject the environment variable only whennoBuild == false
, preserving existing environment variablesProgram.cs
to provideIConfiguration
toDotNetCliRunner
Test Coverage
Added comprehensive tests to verify:
"true"
when not set in configurationnoBuild == false
Technical Implementation Details
✅ Always inject the
DOTNET_CLI_USE_MSBUILD_SERVER
environment variable into the environment dictionary passed to the build/run process for apphost builds✅ The value is sourced from
configuration["DOTNET_CLI_USE_MSBUILD_SERVER"]
with fallback to"true"
✅ Never check for or rely on any preexisting value in the env dictionary; always explicitly set the variable
✅ In
BuildAsync()
: Always inject the variable before callingExecuteAsync
✅ In
RunAsync()
: Inject the variable only ifnoBuild == false
, before callingExecuteAsync
✅
DotNetCliRunner
has access toIConfiguration
instance via dependency injectionTesting
noBuild
parameterThe implementation is minimal and surgical, preserving all existing functionality while adding the required environment variable injection capability.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.