Closed
Description
This issue tracks 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. The key technical implementation details are as follows:
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 should be sourced from configuration["DOTNET_CLI_USE_MSBUILD_SERVER"]. This allows test scenarios to override the value using configuration.
- If configuration["DOTNET_CLI_USE_MSBUILD_SERVER"] is not set, default the value to "true".
- Do not check for or rely on any preexisting value in the env dictionary passed to the runner; always explicitly set the variable.
- In DotNetCliRunner:
- In BuildAsync(...): Always inject the variable before calling ExecuteAsync.
- In RunAsync(...): Inject the variable only if noBuild == false, before calling ExecuteAsync.
- Ensure that the DotNetCliRunner has access to an IConfiguration instance, either via dependency injection or other means.
- Update or add tests to ensure:
- The variable defaults to "true" when not set in configuration.
- The variable can be overridden via configuration for testing or explicit opt-out.
- The environment variable is always present in the effective environment used for the build/run process.