diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index 262d6cd2fc29..9bc820653551 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -107,10 +107,10 @@ public async Task DownloadPackageAsync(PackageId packageId, string nupkgPath = downloadFolder == null || !downloadFolder.HasValue ? Path.Combine(_packageInstallDir.Value, packageId.ToString(), - resolvedPackageVersion.ToNormalizedString(), - $"{packageId}.{resolvedPackageVersion.ToNormalizedString()}.nupkg") + resolvedPackageVersion.ToNormalizedString().ToLowerInvariant(), + $"{packageId}.{resolvedPackageVersion.ToNormalizedString().ToLowerInvariant()}.nupkg") : Path.Combine(downloadFolder.Value.Value, - $"{packageId}.{resolvedPackageVersion.ToNormalizedString()}.nupkg"); + $"{packageId}.{resolvedPackageVersion.ToNormalizedString().ToLowerInvariant()}.nupkg"); Directory.CreateDirectory(Path.GetDirectoryName(nupkgPath)); using FileStream destinationStream = File.Create(nupkgPath); @@ -282,8 +282,8 @@ await GetPackageMetadataAsync(packageId.ToString(), packageVersion, packagesSour } private string GetNupkgUrl(string baseUri, PackageId id, NuGetVersion version) => - baseUri + id.ToString() + "/" + version.ToNormalizedString() + "/" + id.ToString() + - "." + version.ToNormalizedString() + ".nupkg"; + baseUri + id.ToString() + "/" + version.ToNormalizedString().ToLowerInvariant() + "/" + id.ToString() + + "." + version.ToNormalizedString().ToLowerInvariant() + ".nupkg"; internal IEnumerable FindAllFilesNeedExecutablePermission(IEnumerable files, string targetPath) diff --git a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs index 3189520dcf89..d60617fc9816 100644 --- a/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs +++ b/src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs @@ -107,11 +107,11 @@ public IToolPackage InstallPackage(PackageLocation packageLocation, PackageId pa } NuGetVersion packageVersion = nugetPackageDownloader.GetBestPackageVersionAsync(packageId, versionRange, packageSourceLocation).GetAwaiter().GetResult(); - rollbackDirectory = isGlobalTool ? toolDownloadDir.Value: Path.Combine(toolDownloadDir.Value, packageId.ToString(), packageVersion.ToString()); + rollbackDirectory = isGlobalTool ? toolDownloadDir.Value: Path.Combine(toolDownloadDir.Value, packageId.ToString(), packageVersion.ToNormalizedString().ToLowerInvariant()); if (isGlobalTool) { - NuGetv3LocalRepository nugetPackageRootDirectory = new(Path.Combine(_toolPackageStore.GetRootPackageDirectory(packageId).ToString().Trim('"'), packageVersion.ToString())); + NuGetv3LocalRepository nugetPackageRootDirectory = new(Path.Combine(_toolPackageStore.GetRootPackageDirectory(packageId).ToString().Trim('"'), packageVersion.ToNormalizedString().ToLowerInvariant())); var globalPackage = nugetPackageRootDirectory.FindPackage(packageId.ToString(), packageVersion); if (globalPackage != null) @@ -295,7 +295,7 @@ private static async Task DownloadAndExtractPackage( } // Extract the package - var nupkgDir = Path.Combine(packagesRootPath, packageId.ToString(), version.ToString()); + var nupkgDir = Path.Combine(packagesRootPath, packageId.ToString(), version.ToNormalizedString().ToLowerInvariant()); await nugetPackageDownloader.ExtractPackageAsync(packagePath, new DirectoryPath(nupkgDir)); return version; diff --git a/src/Cli/dotnet/ToolPackage/ToolPackageInstance.cs b/src/Cli/dotnet/ToolPackage/ToolPackageInstance.cs index 4bcd76b82bdc..469e5ddba3d3 100644 --- a/src/Cli/dotnet/ToolPackage/ToolPackageInstance.cs +++ b/src/Cli/dotnet/ToolPackage/ToolPackageInstance.cs @@ -74,7 +74,7 @@ public ToolPackageInstance(PackageId id, _lockFile = new Lazy( () => new LockFileFormat().Read(assetsJsonParentDirectory.WithFile(AssetsFileName).Value)); - var toolsPackagePath = Path.Combine(PackageDirectory.Value, Id.ToString(), Version.ToNormalizedString(), "tools"); + var toolsPackagePath = Path.Combine(PackageDirectory.Value, Id.ToString(), Version.ToNormalizedString().ToLowerInvariant(), "tools"); Frameworks = Directory.GetDirectories(toolsPackagePath) .Select(path => NuGetFramework.ParseFolder(Path.GetFileName(path))); } @@ -116,7 +116,7 @@ private FilePath LockFileRelativePathToFullFilePath(string lockFileRelativePath, return PackageDirectory .WithSubDirectories( Id.ToString(), - library.Version.ToNormalizedString()) + library.Version.ToNormalizedString().ToLowerInvariant()) .WithFile(lockFileRelativePath); } @@ -198,7 +198,7 @@ private ToolConfiguration DeserializeToolConfiguration(LockFileTargetLibrary lib PackageDirectory .WithSubDirectories( Id.ToString(), - library.Version.ToNormalizedString()) + library.Version.ToNormalizedString().ToLowerInvariant()) .WithFile(dotnetToolSettings.Path); var configuration = ToolConfigurationDeserializer.Deserialize(toolConfigurationPath.Value); diff --git a/src/Cli/dotnet/commands/dotnet-add/dotnet-add-package/AddPackageParser.cs b/src/Cli/dotnet/commands/dotnet-add/dotnet-add-package/AddPackageParser.cs index 98263a0c4fc7..d8ee2b421303 100644 --- a/src/Cli/dotnet/commands/dotnet-add/dotnet-add-package/AddPackageParser.cs +++ b/src/Cli/dotnet/commands/dotnet-add/dotnet-add-package/AddPackageParser.cs @@ -38,7 +38,7 @@ internal static class AddPackageParser var allowPrerelease = context.ParseResult.GetValue(PrereleaseOption); return QueryVersionsForPackage(packageId, context.WordToComplete, allowPrerelease, CancellationToken.None) .Result - .Select(version => new CompletionItem(version.ToNormalizedString())); + .Select(version => new CompletionItem(version.ToNormalizedString().ToLowerInvariant())); } else { diff --git a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/Mocks/MockPackageResolver.cs b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/Mocks/MockPackageResolver.cs index 94ea855dd214..622e12a1967c 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/Mocks/MockPackageResolver.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/Mocks/MockPackageResolver.cs @@ -22,7 +22,7 @@ public string GetPackageDirectory(string packageId, NuGetVersion version) public string GetPackageDirectory(string packageId, NuGetVersion version, out string packageRoot) { packageRoot = _root; - return Path.Combine(_root, packageId, version.ToNormalizedString(), "path"); + return Path.Combine(_root, packageId, version.ToNormalizedString().ToLowerInvariant(), "path"); } public string ResolvePackageAssetPath(LockFileTargetLibrary package, string relativePath) => Path.Combine(GetPackageDirectory(package.Name, package.Version), relativePath); diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs index e1e9fcf1b39d..d504fe68383b 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs @@ -1442,7 +1442,7 @@ private void WritePackageDependenciesDesignTime() foreach (var package in _lockFile.Libraries) { - var packageVersion = package.Version.ToNormalizedString(); + var packageVersion = package.Version.ToNormalizedString().ToLowerInvariant(); string packageId = $"{package.Name}/{packageVersion}"; // Find PackageDefinitions that match our allowed item specs @@ -1508,7 +1508,7 @@ HashSet GetPackageDependencies() return results; } - static string GetPackageId(LockFileTargetLibrary package) => $"{package.Name}/{package.Version.ToNormalizedString()}"; + static string GetPackageId(LockFileTargetLibrary package) => $"{package.Name}/{package.Version.ToNormalizedString().ToLowerInvariant()}"; Dictionary GetPackageDiagnosticLevels() { diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageDependencies.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageDependencies.cs index f7c7d71f003f..084ced81074d 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageDependencies.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageDependencies.cs @@ -166,7 +166,7 @@ private void GetPackageAndFileDefinitions() foreach (var package in LockFile.Libraries) { var packageName = package.Name; - var packageVersion = package.Version.ToNormalizedString(); + var packageVersion = package.Version.ToNormalizedString().ToLowerInvariant(); string packageId = $"{packageName}/{packageVersion}"; var item = new TaskItem(packageId); item.SetMetadata(MetadataKeys.Name, packageName); @@ -288,7 +288,7 @@ private void GetPackageAndFileDependencies(LockFileTarget target) foreach (var package in target.Libraries) { - string packageId = $"{package.Name}/{package.Version.ToNormalizedString()}"; + string packageId = $"{package.Name}/{package.Version.ToNormalizedString().ToLowerInvariant()}"; if (_projectFileDependencies.Contains(package.Name)) { @@ -313,7 +313,7 @@ private void GetPackageDependencies( Dictionary resolvedPackageVersions, HashSet transitiveProjectRefs) { - string packageId = $"{package.Name}/{package.Version.ToNormalizedString()}"; + string packageId = $"{package.Name}/{package.Version.ToNormalizedString().ToLowerInvariant()}"; string frameworkAlias = _targetNameToAliasMap[targetName]; foreach (var deps in package.Dependencies) { @@ -339,7 +339,7 @@ private void GetPackageDependencies( private void GetFileDependencies(LockFileTargetLibrary package, string targetName) { - string packageId = $"{package.Name}/{package.Version.ToNormalizedString()}"; + string packageId = $"{package.Name}/{package.Version.ToNormalizedString().ToLowerInvariant()}"; string frameworkAlias = _targetNameToAliasMap[targetName]; // for each type of file group