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.71k stars 1.06k forks source link

--create-manifest-if-needed for tool manifest behaviour discussion, and the -d option to list location searched doesn't do what it claims #36830

Open smoothdeveloper opened 11 months ago

smoothdeveloper commented 11 months ago

I've not been able to try it with latest rc2, but wondering if the command still fails due to no manifest, is it advertising the option implemented in #31231?

$ dotnet tool install mytool error, no manifest found, consider running dotnet tool install mytool --create-manifest-if-needed or dotnet new tool-manifest and reruning dotnet tool install mytool. locations searched for: ...

this should be the default (if --create-manifest-if-needed is still explicit opt-in as default, rather than opt out), if it is opt-out it should just go ahead and create the manifest and print the location of it when creating it.

Also, when I run this command in https://github.com/stephan-tolksdorf/fparsec/

$ dotnet -d tool install fsharp-analyzers                                                                                                                                         

I get:

Telemetry is: Enabled Microsoft.DotNet.Cli.Utils.GracefulException: Cannot find a manifest file. For a list of locations searched, specify the "-d" option before the tool name. If you intended to install a global tool, add --global to the command. If you would like to create a manifest, use dotnet new tool-manifest, usually in the repo root directory. at Microsoft.DotNet.Tools.Tool.Install.ToolInstallLocalCommand.GetManifestFilePath() at Microsoft.DotNet.Tools.Tool.Install.ToolInstallLocalCommand.Execute() at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult) at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)

the -d flag doesn't make it list anything, only a more detailed stack trace.

I tried before and after removing global.json from the fparsec repository.

 $ dotnet --info
.NET SDK:
 Version:   8.0.100-rc.2.23502.2
 Commit:    0abacfc2b6

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.4
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/8.0.100-rc.2.23502.2/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.0-rc.2.23479.6
  Architecture: arm64
  Commit:       0b25e38ad3

.NET SDKs installed:
  6.0.400 [/usr/local/share/dotnet/sdk]
  6.0.401 [/usr/local/share/dotnet/sdk]
  6.0.405 [/usr/local/share/dotnet/sdk]
  7.0.100-preview.7.22377.5 [/usr/local/share/dotnet/sdk]
  7.0.100-rc.2.22477.23 [/usr/local/share/dotnet/sdk]
  7.0.102 [/usr/local/share/dotnet/sdk]
  7.0.304 [/usr/local/share/dotnet/sdk]
  8.0.100-preview.5.23303.2 [/usr/local/share/dotnet/sdk]
  8.0.100-preview.6.23330.14 [/usr/local/share/dotnet/sdk]
  8.0.100-rc.1.23463.5 [/usr/local/share/dotnet/sdk]
  8.0.100-rc.2.23502.2 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-preview.7.22376.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-rc.2.22476.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0-preview.5.23302.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0-preview.6.23329.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0-rc.1.23421.29 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0-rc.2.23480.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-preview.7.22375.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-rc.2.22472.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-preview.5.23280.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-preview.6.23329.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-rc.1.23419.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-rc.2.23479.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  x64   [/usr/local/share/dotnet/x64]
    registered at [/etc/dotnet/install_location_x64]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
JL03-Yue commented 11 months ago

Thank you for the suggestion! This is a great suggestions and we'd love to take that into consideration. However, we are also trying to avoid that there could potentially generating manifest file accidentally on unexpected locations, and you could run unexpected tools, as the side effect of creating a manifest file by default. We did take it into consideration when adding the create-manifest-if-needed flag. @baronfel Is there any thought from you on this feature?

smoothdeveloper commented 11 months ago

Adding another outcome I encounter, and reinsures me a tiny bit in my reading comprehension

For a list of locations searched, specify the "-d" option before the tool name.

$ dotnet tool install -d fsharp-analyzers
Unrecognized command or argument 'fsharp-analyzers'.

Description:
  Install global or local tool. Local tools are added to manifest and restored.
... all the help