Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/sdkPublic

Add Windows admin PATH management commands to dotnetup#52181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge14 commits intorelease/dnup
base:release/dnup
Choose a base branch
Loading
fromcopilot/modify-admin-path-windows
Draft
Changes from1 commit
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
a86586f
Initial plan
CopilotDec 16, 2025
542c866
Add WindowsPathHelper and new commands for PATH management
CopilotDec 16, 2025
d8fed6a
Add tests for new PATH management commands
CopilotDec 16, 2025
374d46e
Address code review feedback
CopilotDec 16, 2025
6174dec
Run dotnet format to fix whitespace
CopilotDec 16, 2025
3d163b5
Hide elevatedadminpath command from help output
CopilotDec 16, 2025
5585351
Refactor PATH manipulation to preserve unexpanded environment variables
CopilotDec 16, 2025
1d91179
Refactor WindowsPathHelper to be disposable with progressive logging
CopilotDec 16, 2025
bbd3d5c
Address code review feedback on WindowsPathHelper
CopilotDec 17, 2025
f4e9278
Address additional code review feedback
CopilotDec 17, 2025
8aa862f
Replace IsElevated with Environment.IsPrivilegedProcess and add admin…
CopilotDec 18, 2025
bd56b89
Add overload to display dotnet paths found in admin PATH
CopilotDec 18, 2025
532dcd0
Simplify output and exception handling
dsplaistedDec 18, 2025
b182662
Refactor PATH operations to preserve unexpanded environment variables
CopilotDec 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Address code review feedback
- Extract PATH splitting logic to SplitPath helper method- Remove extra blank lines in WindowsPathHelper.cs- All tests still passCo-authored-by: dsplaisted <145043+dsplaisted@users.noreply.github.com>
  • Loading branch information
@dsplaisted
Copilot anddsplaisted committedDec 16, 2025
commit374d46ecdb45f5d9b51b3352ef997b13fe4771d4

Some comments aren't visible on the classic Files Changed page.

16 changes: 11 additions & 5 deletionssrc/Installer/dotnetup/WindowsPathHelper.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,12 +97,20 @@ public static List<string> GetProgramFilesDotnetPaths()
return paths;
}

/// <summary>
/// Splits a PATH string into entries.
/// </summary>
private static List<string> SplitPath(string path)
{
return path.Split(';', StringSplitOptions.RemoveEmptyEntries).ToList();
}

/// <summary>
/// Removes the Program Files dotnet path from the given PATH string.
/// </summary>
public static string RemoveProgramFilesDotnetFromPath(string path)
Copy link
Member

Choose a reason for hiding this comment

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

This method is currently only called by tests, and it has similar but different logic to the real logic. Change this so that it takes both an unexpanded and expanded path as a parameter, and does the logic currently in RemoveProgramFilesDotnetFromAdminPath. Then that method can call this one.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed in commitbbd3d5c. RefactoredRemoveProgramFilesDotnetFromPath to take bothunexpandedPath andexpandedPath as parameters:

publicstaticstringRemoveProgramFilesDotnetFromPath(stringunexpandedPath,stringexpandedPath)

The method now does the logic that was inRemoveProgramFilesDotnetFromAdminPath, which now just calls this method. Tests updated to pass both parameters.

{
var pathEntries =path.Split(';', StringSplitOptions.RemoveEmptyEntries).ToList();
var pathEntries =SplitPath(path);
var programFilesDotnetPaths = GetProgramFilesDotnetPaths();

// Remove entries that match Program Files dotnet paths (case-insensitive)
Expand All@@ -121,7 +129,7 @@ public static string RemoveProgramFilesDotnetFromPath(string path)
/// </summary>
public static string AddProgramFilesDotnetToPath(string path)
Copy link
Member

Choose a reason for hiding this comment

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

This process needs to be changed so that if the PATH needs to be modified, it reads the unexpanded path and then adds to that.

Reuse existing methods for similar functionality if possible. Refactor if you need to.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed in commitb182662. RefactoredAddProgramFilesDotnetToPath() to take bothunexpandedPath andexpandedPath parameters. The method now:

  • Uses the expanded PATH for detection (to check if dotnet is already present)
  • Modifies the unexpanded PATH (to preserve environment variables like%ProgramFiles%,%USERPROFILE%, etc.)

UpdatedAddDotnetToAdminPath() to read both expanded and unexpanded admin PATH and pass both to the helper method.

{
var pathEntries =path.Split(';', StringSplitOptions.RemoveEmptyEntries).ToList();
var pathEntries =SplitPath(path);
var programFilesDotnetPaths = GetProgramFilesDotnetPaths();

// Get the primary Program Files dotnet path (non-x86)
Expand DownExpand Up@@ -153,7 +161,7 @@ public static string AddProgramFilesDotnetToPath(string path)
public static bool AdminPathContainsProgramFilesDotnet()
{
var adminPath = ReadAdminPath();
var pathEntries =adminPath.Split(';', StringSplitOptions.RemoveEmptyEntries);
var pathEntries =SplitPath(adminPath);
var programFilesDotnetPaths = GetProgramFilesDotnetPaths();

return pathEntries.Any(entry =>
Expand DownExpand Up@@ -190,8 +198,6 @@ public static void LogPathChange(string operation, string oldPath, string newPat
}
}



/// <summary>
/// Broadcasts a WM_SETTINGCHANGE message to notify other applications that the environment has changed.
/// </summary>
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp