Skip to content

Honor Configuration environment variable in CLI options#55431

Open
Evangelink wants to merge 3 commits into
dotnet:mainfrom
Evangelink:dev/amauryleve/fix-sdk-issue-52358
Open

Honor Configuration environment variable in CLI options#55431
Evangelink wants to merge 3 commits into
dotnet:mainfrom
Evangelink:dev/amauryleve/fix-sdk-issue-52358

Conversation

@Evangelink

@Evangelink Evangelink commented Jul 23, 2026

Copy link
Copy Markdown
Member

Addresses the Configuration environment-variable regression in #52358.

Summary

  • seed the shared -c/--configuration option from the Configuration environment variable
  • ignore empty or whitespace-only environment values
  • preserve precedence for an explicit --configuration value
  • add parser coverage and an end-to-end MTP solution regression test

This follows the approach suggested in the issue discussion and applies consistently to commands using the shared configuration option. A standalone Platform environment variable remains outside this change because there is no equivalent shared CLI option.

Validation

  • build.cmd
  • 15 focused dotnet.Tests tests covering CommonOptionsTests and the MTP solution regression scenario

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 72bf4a4e-15d3-4177-9246-c49ad3071b13
Copilot AI review requested due to automatic review settings July 23, 2026 14:19
@Evangelink
Evangelink requested review from a team as code owners July 23, 2026 14:19
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 restores/extends CLI behavior so the shared -c/--configuration option can default from the Configuration environment variable (addressing the regression reported in #52358), while ensuring explicit CLI values and /p:Configuration continue to take precedence.

Changes:

  • Seed --configuration from the Configuration environment variable and forward it as --property:Configuration=....
  • Preserve precedence when --property:Configuration=... is explicitly provided (don’t let the implicit env-derived configuration override it).
  • Add parser-level tests and an end-to-end dotnet test regression test for solution execution.
Show a summary per file
File Description
test/dotnet.Tests/ParserTests/CommonOptionsTests.cs Adds parser tests validating env-defaulting and precedence rules for configuration forwarding.
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTestsWithDifferentOptions.cs Adds an end-to-end regression test asserting dotnet test honors Configuration env var when --configuration is not passed.
src/Cli/Microsoft.DotNet.Cli.Definitions/Common/CommonOptions.cs Implements env-based defaulting for --configuration and adds forwarding logic to avoid overriding explicit /p:Configuration.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread src/Cli/Microsoft.DotNet.Cli.Definitions/Common/CommonOptions.cs Outdated
Comment thread src/Cli/Microsoft.DotNet.Cli.Definitions/Common/CommonOptions.cs Outdated
@baronfel baronfel added Area-dotnet test Area-CLI cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on) labels Jul 23, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 72bf4a4e-15d3-4177-9246-c49ad3071b13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-CLI Area-dotnet test cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants