Description
GlobalToolsSuggestionRegistration returns suggestion registrations for all executables in ~/.dotnet/tools/, and dotnet-suggest
can then run such executables with the [suggest]
directive even if they have not been explicitly registered. However, supporting this directive is not a requirement for creating a .NET tool. For example, dotnet-runtimeinfo 1.0.4, dotnet-script 1.1.0, and microsoft.visualstudio.slngen.tool 8.5.0 do not support it. There is a risk that the tool does something unexpected when given '[suggest]' which it does not recognize as a directive. For example, it could create a file with that name, or spend time trying to connect to a computer with that name.
I think the best solution would be:
- Add something into the DotnetToolSettings.xml file to indicate that the command supports
[suggest]
. If it becomes possible to have multiple commands in the same tool package, this information should be specific to each command. The GenerateToolsSettingsFile task in .NET SDK generates DotnetToolSettings.xml and could read some property that the System.CommandLine package would set by default. - Make
dotnet tool install
copy this information to some place from whichdotnet-suggest
can find it, regardless of whetherdotnet-suggest
has been installed. For example, place it in ~/.dotnet/tools-suggest.json, or copy the whole XML file to tools/.meta/command/DotnetToolSettings.xml. - Make
dotnet-suggest
consult the information from step 2 to ascertain whether the command supports[suggest]
.
If a tool supports [suggest]
but is too old to include this information in its DotnetToolSettings.xml file, then the user can dotnet-suggest register
it manually.
I also considered adding some AssemblyMetadataAttribute to the entry point assembly of the command, but that doesn't really seem any easier because the executables in ~/.dotnet/tools/ are shims that don't contain CLR metadata. Also it would not be so easily extensible to wholly unmanaged tools.