Fix case-sensitive path comparison in GlobalSettingsTemplatePackageProvider.EnsureInstallPrerequisites#55105
Open
Happypig375 wants to merge 2 commits into
Open
Conversation
…emplate packages The EnsureInstallPrerequisites method in GlobalSettingsTemplatePackageProvider used ordinal (case-sensitive) comparison (s.Identifier == identifier) to check if a managed template package is already installed. On Windows, file paths can have different drive letter casing (e.g., 'c:\path' vs 'C:\path'), causing the check to miss existing packages. When --force re-installs a folder template with different path casing, the old entry is not detected as a duplicate, so both survive. This leads to the template cache reporting overlapping identity conflicts. Fix by using StringComparison.OrdinalIgnoreCase to match the behavior of ValidateInstallationRequestsAsync and DetermineSourcesToUninstallAsync which already use case-insensitive comparison.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes duplicate managed template-package entries caused by case-sensitive identifier comparison when reinstalling the same local template path with different casing (notably drive-letter casing on Windows).
Changes:
- Switches the “already installed” check in
GlobalSettingsTemplatePackageProvider.EnsureInstallPrerequisitesto useStringComparison.OrdinalIgnoreCasefor identifier comparison.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Description
The
EnsureInstallPrerequisitesmethod inGlobalSettingsTemplatePackageProvideruses ordinal (case-sensitive) comparison (s.Identifier == identifier) to detect if a managed template package is already installed. On Windows, file paths can have different drive letter casing (e.g.,c:\pathvsC:\path), causing the check to miss existing packages.Repro
The second command succeeds but doesn't remove the old entry (because
"c:\..." != "C:\..."with ordinal comparison). Both packages survive, and the template cache reports overlapping identity conflicts:Fix
Changed
s.Identifier == identifierto usestring.Equals(s.Identifier, identifier, StringComparison.OrdinalIgnoreCase).This matches the behavior of
TemplatePackageCoordinator.ValidateInstallationRequestsAsyncandTemplatePackageCoordinator.DetermineSourcesToUninstallAsyncwhich already use case-insensitive comparison.