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.6k stars 1.04k forks source link

dotnet tool restore results in FileNotFoundException on linux due to case sensitivity issue #41844

Closed blueboxes closed 6 days ago

blueboxes commented 3 weeks ago

Describe the bug

I have a dotnet tool pre-release version pushed to Azure DevOps Artifact feed and try an use this with a linux build agent I get file not found.

To Reproduce

Create a tool that has an upper case pre-release version tag e.g. 1.1.-MyTestVersion

Run dotnet tool install -g packagename --prerelease on a linux machine.

It finds the correct version from the feed to install but fails with a FileNotFoundException path error as it is looking for a lowercase version tag in the path.

I found this on a MS-hosted azure devops build agent. The dotnet tool package was pushed using the same agent setup.

Exceptions (if any)

packagename/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/home/vsts/work/_temp/2dcf1cae-d439-4db9-9980-749bd81a32f7.ps1'
Unhandled exception: System.IO.FileNotFoundException: Could not find file '/home/vsts/.dotnet/tools/.store/.stage/rkh2gf0n.kaw/packagename/1.1.4-228774mytestversion/packagename.1.1.4-228774mytestversion.nupkg'.
File name: '/home/vsts/.dotnet/tools/.store/.stage/rkh2gf0n.kaw/packagename/1.1.4-228774mytestversion/packagename.1.1.4-228774mytestversion.nupkg'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at NuGet.Protocol.LocalFolderUtility.<>c__DisplayClass48_0.<GenerateNupkgMetadataFile>b__0()
   at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLocked(String filePath, Action action, Func`2 acquireFileStream, Int32 numberOfRetries)
   at NuGet.Repositories.NuGetv3LocalRepository.GetPackage(String packageId, NuGetVersion version, String path)
   at NuGet.Repositories.NuGetv3LocalRepository.FindPackageImpl(String packageId, NuGetVersion version)
   at NuGet.Repositories.NuGetv3LocalRepository.FindPackage(String packageId, NuGetVersion version)
   at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.CreateAssetFile(PackageId packageId, NuGetVersion version, DirectoryPath packagesRootPath, DirectoryPath assetFileDirectory, String runtimeJsonGraph, String targetFramework)
   at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.<>c__DisplayClass8_0.<InstallPackage>b__0()
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.<>c__DisplayClass20_0.<Execute>b__1()
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.RunWithHandlingInstallError(Action installAction)
   at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.Execute()
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)

I found issue #11038 but it looks to be diffrent.

KalleOlaviNiemitalo commented 3 weeks ago

This looks similar to https://github.com/dotnet/sdk/issues/39105.

blueboxes commented 3 weeks ago

Happy to close as duplicate

Forgind commented 6 days ago

Closing as a duplicate of #39105. Thanks for finding that @KalleOlaviNiemitalo!