diff --git a/doc/ReleaseNotes.md b/doc/ReleaseNotes.md index 2b818a30e1..d1358f5c5e 100644 --- a/doc/ReleaseNotes.md +++ b/doc/ReleaseNotes.md @@ -14,5 +14,6 @@ To use the feature, try `winget source edit winget-font` to set the Explicit sta ## Bug Fixes +* Portable Packages now use the correct directory separators regardless of which convention is used in the manifest * `--suppress-initial-details` now works with `winget configure test` * `--suppress-initial-details` no longer requires `--accept-configuration-agreements` 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); }; }