oleg-shilo / cs-script

C# scripting platform
http://www.cs-script.net
MIT License
1.56k stars 234 forks source link

DirectoryNotFoundException using dotnet tool install -g CS-Script #369

Open SchreinerK opened 2 months ago

SchreinerK commented 2 months ago

dotnet tool install -g CS-Script

Die Überprüfung der NuGet-Paketsignatur wird übersprungen. Unhandled exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Kay.dotnet\tools\.store\cs-script\4.8.14\cs-script\4.8.14\tools'. at System.IO.Enumeration.FileSystemEnumerator1.CreateDirectoryHandle(String path, Boolean ignoreNotFound) at System.IO.Enumeration.FileSystemEnumerator1.Init() at System.IO.Enumeration.FileSystemEnumerable1..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 Microsoft.DotNet.ToolPackage.ToolPackageInstance..ctor(PackageId id, NuGetVersion version, DirectoryPath packageDirectory, DirectoryPath assetsJsonParentDirectory) at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.<>c__DisplayClass8_0.<InstallPackage>b__0() at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func1 action, Action commit, Action rollback) at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.<>c__DisplayClass18_0.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 dont know if this is related to the cs-script package or something wrong with dotnet tool installer. C:\Users\Kay\.dotnet\tools.store exists and is active used for the other tools.

image

oleg-shilo commented 2 months ago

Hm... interesting.

It is a .NET error. The call stack there is all .NET API.

Though, on my system, it throws the same error. This discussion suggests that this type of error is raised when the package spec does not indicate the correct package type: https://github.com/dotnet/sdk/issues/37010

Though cs-script package does have the correct type: image

Unless they have changed the package type value again. Will need to dig into it.

oleg-shilo commented 2 months ago

WOW, not sure what is going on in the NuGet land.

Installing the the first, latest and some intermediate versions works just fine:

image

Note the last install on the screenshot, dotnet tool install --global cs-script.cli, it also install fine. But just a minute ago it was failing with the same error as yours

oleg-shilo commented 2 months ago

OMG I see it LOL

You and I have made the same mistake. We were trying to install not a tool but a package (a class library)

.NET Tool: cs-script.cli .NET package: cs-script

Well, that is a complete solution to the problem :)