dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.66k stars 1.06k forks source link

dotnet tool install fails if version contains uppercase #24419

Open gjhommersom opened 2 years ago

gjhommersom commented 2 years ago

Describe the bug

Running dotnet tool install --version with a version that contains an uppercase the installation fails.

To Reproduce

  1. docker run -it mcr.microsoft.com/dotnet/sdk sh
  2. dotnet new tool-manifest --name=test
  3. dotnet tool install MyTool --version 1.2.10-20220317T100234.git-58c4dfc

Important to note is that the directory where the package is installed uses lowercase for the version. The executed command seems to use the uppercase (see exception).

Issue does not reproduce on Windows.

Exceptions (if any)

System.IO.DirectoryNotFoundException: Could not find a part of the path '/root/.nuget/packages/mytool/1.2.10-20220317T100234.git-58c4dfc/tools'.
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
   at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
   at System.IO.Enumeration.FileSystemEnumerableFactory.UserDirectories(String directory, String expression, EnumerationOptions options)
   at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at System.IO.Directory.GetDirectories(String path, String searchPattern, EnumerationOptions enumerationOptions)
   at System.IO.Directory.GetDirectories(String path)
   at Microsoft.DotNet.ToolPackage.ToolPackageInstance..ctor(PackageId id, NuGetVersion version, DirectoryPath packageDirectory, DirectoryPath assetsJsonParentDirectory)
   at Microsoft.DotNet.ToolPackage.ToolPackageInstance.CreateFromAssetFile(PackageId id, DirectoryPath assetsJsonParentDirectory)
   at Microsoft.DotNet.ToolPackage.ToolPackageInstaller.InstallPackageToExternalManagedLocation(PackageLocation packageLocation, PackageId packageId, VersionRange versionRange, String targetFramework, String verbosity)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallLocalInstaller.Install(FilePath manifestFile)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallLocalCommand.Install(FilePath manifestFile)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallLocalCommand.Execute()
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallCommand.Execute()
   at Microsoft.DotNet.Cli.DotNetTopLevelCommandBase.RunCommand(String[] args)
   at Microsoft.DotNet.Tools.Tool.ToolCommand.Run(String[] args)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

Further technical details

# dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.201
 Commit:    ef40e6aa06

Runtime Environment:
 OS Name:     debian
 OS Version:  11
 OS Platform: Linux
 RID:         debian.11-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.201/

Host (useful for support):
  Version: 6.0.3
  Commit:  c24d9a9c91

.NET SDKs installed:
  6.0.201 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
OskiKervinen-MF commented 10 months ago

I ran into this as well. The package folder exists on disk, with the version part all in lower case. The installation looks for it with the upper case and fails. I tried specifying the version in lower case, but that did not help; I presume the version used in the path comes from the feed. The only work around I found was to rename the on-disk folder to have the correct casing, but that is an awful contortion to go through.

janstaelensskyline commented 3 weeks ago

Ran into this as well. Only way around this is to rename the folder as specified above or release a new version with lower case.