Dotnetup: Modify PowerShell profile on Windows#54520
Open
dsplaisted wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Windows PowerShell profile support for dotnetup’s shell-profile environment setup, so init can configure PowerShell profiles on Windows in addition to Unix shells.
Changes:
- Adds Windows PowerShell and PowerShell Core profile path resolution using
profile.ps1. - Updates terminal profile modification flow to support Windows and system/user profile entries.
- Adds/updates tests and design documentation for PowerShell profile paths and profile entry behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Installer/dotnetup.Library/Shell/PowerShellEnvShellProvider.cs |
Resolves PowerShell profile paths for Windows and switches to all-hosts profile.ps1. |
src/Installer/dotnetup.Library/DotnetEnvironmentManager.cs |
Routes terminal profile updates through Windows/Unix-specific logic. |
src/Installer/dotnetup.Library/IDotnetEnvironmentManager.cs |
Updates the interface signature and documentation for install-type-aware profile changes. |
src/Installer/dotnetup.Library/Commands/Init/InitWorkflows.cs |
Calls profile modification with the updated API. |
test/dotnetup.Tests/ShellProfileManagerTests.cs |
Adds coverage for Windows profile paths and environment manager profile entry behavior. |
test/dotnetup.Tests/MockDotnetInstallManager.cs |
Updates test mock to match the interface signature. |
test/dotnetup.Tests/DefaultInstallCommandTests.cs |
Updates expected Unix PowerShell profile filename. |
documentation/general/dotnetup/designs/unix-environment-setup.md |
Documents Unix and Windows PowerShell profile locations. |
|
|
||
| return | ||
| [ | ||
| Path.Combine(documentsFolder, WindowsPowerShellProfileFolder, ProfileFileName), |
Comment on lines
+346
to
+361
| if (installType == InstallType.System) | ||
| { | ||
| // System install: dotnet is assumed to be on PATH already (configured by the system | ||
| // installer / admin). The profile entry only adds dotnetup to PATH. | ||
| ShellProfileManager.AddProfileEntries(shellProvider, dotnetupPath, dotnetupOnly: true); | ||
| return; | ||
| } | ||
|
|
||
| // If the install root matches the default dotnetup-managed path, omit it from the profile | ||
| // entry so `print-env-script` falls back to its built-in default-detection logic. This | ||
| // keeps profile entries minimal and portable across user-resolved default paths. | ||
| string? profileDotnetRoot = DotnetupUtilities.PathsEqual(dotnetRoot, GetDefaultDotnetInstallPath()) | ||
| ? null | ||
| : dotnetRoot; | ||
|
|
||
| ShellProfileManager.AddProfileEntries(shellProvider, dotnetupPath, dotnetInstallPath: profileDotnetRoot); |
| shellProvider = ShellDetection.GetCurrentShellProviderOrThrow(shellProvider); | ||
|
|
||
| switch (installType) | ||
| if (installType == InstallType.System) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #53962
There are other improvements to the experience and the code that we'd like to make, but this gets the basic functionality working.