Skip to content

Honor Configuration environment variable in CLI options - #55431

Merged
Evangelink merged 4 commits into
dotnet:mainfrom
Evangelink:dev/amauryleve/fix-sdk-issue-52358
Jul 24, 2026
Merged

Honor Configuration environment variable in CLI options#55431
Evangelink merged 4 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
  • avoid rendering empty dynamic defaults as [] in custom help
  • update CLI schema expectations for the new default factory
  • 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
  • 21 focused dotnet.Tests tests covering CommonOptionsTests, CLI schema output, MTP help, 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
Evangelink and others added 2 commits July 23, 2026 21:48
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 72bf4a4e-15d3-4177-9246-c49ad3071b13
@Evangelink

Copy link
Copy Markdown
Member Author

/ba-g #40074

@Evangelink
Evangelink merged commit 01968e2 into dotnet:main Jul 24, 2026
26 of 28 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/fix-sdk-issue-52358 branch July 24, 2026 11:06
@Evangelink

Copy link
Copy Markdown
Member Author

/backport to release/11.0.1xx-preview7

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx-preview7 (link to workflow run)

@Youssef1313 Youssef1313 added breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug needs-breaking-change-doc-created labels Jul 24, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Added needs-breaking-change-doc-created label because this PR has the breaking-change label.

When you commit this breaking change:

  1. Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the breaking change documentation template, then remove this needs-breaking-change-doc-created label.
  2. Ask a committer to mail the .NET SDK Breaking Change Notification email list.

You can refer to the .NET SDK breaking change guidelines

@0xced

0xced commented Aug 20, 2026

Copy link
Copy Markdown

Is there a chance for this to be backported to the .NET 10 SDK?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-CLI Area-dotnet test breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug cli-ux Issues and PRs that deal with the UX of the CLI (exit codes, log output, verbs/options, and so on) needs-breaking-change-doc-created

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants