Skip to content

Forward DOTNET_ROOT and DOTNET_HOST_PATH to BuildHost - #85195

Merged
jjonescz merged 5 commits into
dotnet:mainfrom
jjonescz:dotnet-root
Sep 10, 2026
Merged

Forward DOTNET_ROOT and DOTNET_HOST_PATH to BuildHost#85195
jjonescz merged 5 commits into
dotnet:mainfrom
jjonescz:dotnet-root

Conversation

@jjonescz

@jjonescz jjonescz commented Sep 7, 2026

Copy link
Copy Markdown
Member

Fixes #85194.
Fixes #71019.

Microsoft Reviewers: Open in CodeFlow

@jjonescz
jjonescz requested a balanced review from Copilot September 7, 2026 16:09
@jjonescz
jjonescz requested a review from a team as a code owner September 7, 2026 16:09
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
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.

🟡 Changes recommended

Inherited architecture-specific DOTNET_ROOT variables can override the selected installation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes BuildHost SDK selection when relaunching with a selected .NET installation.

Changes:

  • Sets DOTNET_ROOT variables for explicit dotnet paths.
  • Adds regression coverage for explicit and default paths.
File summaries
File Description
src/Workspaces/MSBuild/Test/BuildHostProcessManagerTests.cs Tests BuildHost environment handling; architecture-specific coverage is still needed.
src/Workspaces/MSBuild/Core/MSBuild/BuildHostProcessManager.cs Configures .NET roots, but inherited architecture-specific DOTNET_ROOT* variables remain uncleared.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/Workspaces/MSBuild/Core/MSBuild/BuildHostProcessManager.cs Outdated
Copilot AI review requested due to automatic review settings September 8, 2026 07:15

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.

🟡 Changes recommended

The tests mutate process-global environment variables without disabling parallel execution, risking unrelated test failures.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/Workspaces/MSBuild/Test/BuildHostProcessManagerTests.cs
{
// Clear architecture-specific roots so they cannot override the selected installation.
foreach (var key in processStartInfo.Environment.Keys
.Where(static key => key.StartsWith("DOTNET_ROOT", StringComparison.OrdinalIgnoreCase))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: environment variables case sensitivity is determined by OS.

.Where(static key => key.StartsWith("DOTNET_ROOT", StringComparison.OrdinalIgnoreCase))
.ToArray())
{
processStartInfo.Environment.Remove(key);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user specified a dotnet root, shouldn't we respect it? Isn't that what a CLI build would use?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind - if we discovered the dotnet root already this is probably just setting it to the same thing?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be my hunch.

@jasonmalinowski

Copy link
Copy Markdown
Member

You might also get to close #71019 with this, but I admit I don't remember what that all meant...

@jjonescz jjonescz changed the title Fix BuildHost DOTNET_ROOT Forward DOTNET_ROOT and DOTNET_HOST_PATH to BuildHost Sep 9, 2026
Copilot AI review requested due to automatic review settings September 9, 2026 09:38

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.

🟢 Approval recommended

The reviewed changes have regression coverage and no unresolved issues.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@jjonescz
jjonescz merged commit 0f498ab into dotnet:main Sep 10, 2026
23 checks passed
@jjonescz
jjonescz deleted the dotnet-root branch September 10, 2026 07:17
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BuildHost does not set DOTNET_ROOT Correctly respect DOTNET_HOST_PATH in MSBuildWorkspace

6 participants