sdk: Cannot install prereleased tool package from dotnet-install-tool without specifying the exact version

To install a prerelease version of a CLI tool, users must know the exact version they want to install. This means they have to open a browser to nuget.org or myget.org to find the package.

For example, this is the console output for dotnet-watch

> dotnet install tool --global dotnet-watch --source https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json
Install failed. Failed to download package:
NuGet returned:

Failed to restore package.
WorkingDirectory:
Arguments: restore C:\Users\namc\AppData\Local\Temp\0rc552nv.kmy\wjh4elju.lgh.csproj --source https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json --runtime win10-x64 /p:BaseIntermediateOutputPath=\"C:\Users\namc\.dotnet\tools\dotnet-watch\gx5ifack.dyr\"
Output:   Restoring packages for C:\Users\namc\AppData\Local\Temp\0rc552nv.kmy\wjh4elju.lgh.csproj...
C:\Users\namc\AppData\Local\Temp\0rc552nv.kmy\wjh4elju.lgh.csproj : error NU1103: Unable to find a stable package dotnet-watch with version

C:\Users\namc\AppData\Local\Temp\0rc552nv.kmy\wjh4elju.lgh.csproj : error NU1103:   - Found 124 version(s) in https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json [ Nearest version: 2.1.0-preview1-27934 ]
C:\Users\namc\AppData\Local\Temp\0rc552nv.kmy\wjh4elju.lgh.csproj : error NU1103:   - Found 1 version(s) in C:\Users\namc\.dotnet\x64\sdk\NuGetFallbackFolder [ Nearest version: 2.1.0-preview1-28124 ]
  Restore failed in 680.98 ms for C:\Users\namc\AppData\Local\Temp\0rc552nv.kmy\wjh4elju.lgh.csproj.

Usage: dotnet install tool [options] <PACKAGE_ID>

Arguments:
  <PACKAGE_ID>   NuGet Package Id of the tool to install.

Options:
  -g, --global        Install user wide.
  --version           Version of the tool package in NuGet.
  --configfile        The NuGet configuration file to use.
  --source <SOURCE>   Specifies a NuGet package source to use during installation.
  -f, --framework     The target framework to install the tool for.
  -h, --help          Show help information.

This is the console output when trying to specify --version 2.1.0-*

> dotnet install tool --global dotnet-watch --version 2.1.0-* --source https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json
System.ArgumentException: Illegal characters in path.
Parameter name: path
   at System.IO.Path.GetFullPath(String path)
   at System.IO.Directory.CreateDirectory(String path)
   at Microsoft.DotNet.ToolPackage.ToolPackageObtainer.EnsureDirectoryExists(DirectoryPath path)
   at Microsoft.DotNet.ToolPackage.ToolPackageObtainer.CreateIndividualToolVersionDirectory(String packageId, PackageVersion packageVersion)

   at Microsoft.DotNet.ToolPackage.ToolPackageObtainer.ObtainAndReturnExecutablePath(String packageId, String packageVersion, Nullable`1 nugetconfig, String targetframework, String source)
   at Microsoft.DotNet.Tools.Install.Tool.InstallToolCommand.ObtainPackage(DirectoryPath executablePackagePath, DirectoryPath offlineFeedPath)
   at Microsoft.DotNet.Tools.Install.Tool.InstallToolCommand.Execute()
   at Microsoft.DotNet.Cli.DotNetTopLevelCommandBase.RunCommand(String[] args)
   at Microsoft.DotNet.Tools.Install.InstallCommand.Run(String[] args)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

Ideas

  • Support wildcards --version 2.1.0-*
  • Support a --prerelease flag

cc @KathleenDollard

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 17
  • Comments: 61 (35 by maintainers)

Most upvoted comments

What is the status of this issue? Installing latest pre-release tool is a badly needed scenario.

That was bad formatting on my side.

The value is *-*.

And will mean: Give me the latest version & and I’m ok if that latest version is prerelease. So it would select 2.0.0.

@aolszowka

Try --version "*-*"

It’s basically what https://github.com/dotnet/sdk/issues/9037#issuecomment-581651532 enabled.

@DamianEdwards , that works if you already know the exact major.minor.revision, it does not express the intend to install the latest pre-release. Something like dotnet tool install --pre or dotnet tool install --version *-* is helpful.

@peterhuene The ask I linked is to support prerelease in floating ranges.

@wli3 iirc, that was for the immediate release (2.1.3xx), not long term.

We definitely want to add support for installing latest prerelease in PackageReference.

From a CLI experience viewpoint, there should be 3 scenarios right?

  1. specific version/version range, resolved as per NuGet’s PR resolution strategy.
  2. no version provided, which defaults to latest stable, in which case the CLI forwards * to NuGet.
  3. no version provided, with a prerelease option, in which case the CLI forwards *-* or whatever the terminology for latest prerelease included package is.

Anything else?

I think the issue is open because the switch has not been added yet.

I’m not the owner though, so it’s just a guess 😃

@rrelyea can give firm commitment. We’d certainly like to get it done, and an extra scenario like this certainly would elevate the priority.

@wli3 Right, that was the conclusion for 2.1.3xx, but I mean going forward if we want to support --prerelease.

I don’t think a --prerelease option for dotnet install tool makes sense since the package is being installed via a restore operation and the proper way to enable installing pre-release packages via this mechanism is with a version suffix wildcard.

I’m not sure I understand this reasoning. The NuGet cmd line experience (and UI) has always had the concept of “please install whatever is the latest version of this package, including pre-releases”. That is no less applicable in the case of global tools, and while the wildcard support is good, it’s in no way the idiomatic way to do this in NuGet. Very few people know about (and even less use) version ranges or wildcards in NuGet.