From af3031e039e5f175882bed73539fb4abc756606a Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Fri, 10 Oct 2025 13:52:29 -0500 Subject: [PATCH 1/2] Normalize directory separators when adding packages to path --- src/AppInstallerCLICore/PortableInstaller.cpp | 11 ++++++++--- src/AppInstallerCLICore/PortableInstaller.h | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/AppInstallerCLICore/PortableInstaller.cpp b/src/AppInstallerCLICore/PortableInstaller.cpp index 141f0195cb..71b1bc2176 100644 --- a/src/AppInstallerCLICore/PortableInstaller.cpp +++ b/src/AppInstallerCLICore/PortableInstaller.cpp @@ -359,8 +359,11 @@ namespace AppInstaller::CLI::Portable } } - void PortableInstaller::AddToPathVariable(const std::filesystem::path& value) + void PortableInstaller::AddToPathVariable(std::filesystem::path value) { + // Ensure the preferred separator format + value.make_preferred(); + if (PathVariable(GetScope()).Append(value)) { AICLI_LOG(Core, Info, << "Appending portable target directory to PATH registry: " << value); @@ -372,7 +375,7 @@ namespace AppInstaller::CLI::Portable } } - void PortableInstaller::RemoveFromPathVariable(const std::filesystem::path& value) + void PortableInstaller::RemoveFromPathVariable(std::filesystem::path value) { if (std::filesystem::exists(value) && !std::filesystem::is_empty(value)) { @@ -380,7 +383,9 @@ namespace AppInstaller::CLI::Portable } else { - if (PathVariable(GetScope()).Remove(value)) + // Attempt to remove both the original and the preferred format to ensure removal + // Necessary for handling old path values associated with winget-cli#5033 + if (PathVariable(GetScope()).Remove(value) || PathVariable(GetScope()).Remove(value.make_preferred())) { InstallDirectoryAddedToPath = false; AICLI_LOG(CLI, Info, << "Removed target directory from PATH registry: " << value); diff --git a/src/AppInstallerCLICore/PortableInstaller.h b/src/AppInstallerCLICore/PortableInstaller.h index 5dec25063f..affdcc8756 100644 --- a/src/AppInstallerCLICore/PortableInstaller.h +++ b/src/AppInstallerCLICore/PortableInstaller.h @@ -113,7 +113,7 @@ namespace AppInstaller::CLI::Portable void CreateTargetInstallDirectory(); void RemoveInstallDirectory(); - void AddToPathVariable(const std::filesystem::path& value); - void RemoveFromPathVariable(const std::filesystem::path& value); + void AddToPathVariable(std::filesystem::path value); + void RemoveFromPathVariable(std::filesystem::path value); }; } From 454c4b1e21e480c7ef592d8a483f93f92c362162 Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Tue, 14 Oct 2025 20:30:16 -0500 Subject: [PATCH 2/2] Update release notes --- doc/ReleaseNotes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/ReleaseNotes.md b/doc/ReleaseNotes.md index 8ec1e210c6..781fa6db71 100644 --- a/doc/ReleaseNotes.md +++ b/doc/ReleaseNotes.md @@ -1,3 +1,6 @@ ## New in v1.28 + +## Bug Fixes +* Portable Packages now use the correct directory separators regardless of which convention is used in the manifest