Skip to content

Commit

Permalink
[FIX] Save package files with lowercase versions
Browse files Browse the repository at this point in the history
  • Loading branch information
edvilme committed Oct 10, 2024
1 parent b738f3c commit 235af9c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ public async Task<string> 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);
Expand Down Expand Up @@ -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<FilePath> FindAllFilesNeedExecutablePermission(IEnumerable<string> files,
string targetPath)
Expand Down
6 changes: 3 additions & 3 deletions src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -295,7 +295,7 @@ private static async Task<NuGetVersion> 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;
Expand Down
6 changes: 3 additions & 3 deletions src/Cli/dotnet/ToolPackage/ToolPackageInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public ToolPackageInstance(PackageId id,
_lockFile =
new Lazy<LockFile>(
() => 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)));
}
Expand Down Expand Up @@ -116,7 +116,7 @@ private FilePath LockFileRelativePathToFullFilePath(string lockFileRelativePath,
return PackageDirectory
.WithSubDirectories(
Id.ToString(),
library.Version.ToNormalizedString())
library.Version.ToNormalizedString().ToLowerInvariant())
.WithFile(lockFileRelativePath);
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1508,7 +1508,7 @@ HashSet<string> 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<string, LogLevel> GetPackageDiagnosticLevels()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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))
{
Expand All @@ -313,7 +313,7 @@ private void GetPackageDependencies(
Dictionary<string, string> resolvedPackageVersions,
HashSet<string> 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)
{
Expand All @@ -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
Expand Down

0 comments on commit 235af9c

Please sign in to comment.