RegisterWithDotnetSuggest does not work if `dotnet-suggest` is installed later
RegisterWithDotnetSuggest() uses a sentinel file and effectively only (tries to) register once. A good thing in itself, but if the user installs dotnet-suggest after the System.CommandLine application, then the registration fails (of course) and is never attempted again.
This requires the user to either run dotnet-suggest register explicitly, or remove the (obscure, undocumented) sentinel file.
This is not an uncommon scenario:
- software states "supports command completion"
- user installs software and finds out command completion does not work
- user seeks help and finds out dotnet-suggest + shim need to be installed
- user install dotnet-suggest + shim as instructed
- command completion still does not work, as the software never attempts to register again
The IntelliSense for the developer (me in this case) isn't very helpful either, as RegisterWithDotnetSuggest() says: "ensures that ...", while nothing is really ensured.
To add some scenarios here, as I just analyzed some strange behaviour:
If the user moved the executable, after it was registered, the completition is no longer possible e.g. download a zip file with a command, first extract it to some temp location, execute it, test it, later on move it to another location.
also i observed, that after registering for dotnet-suggest, i needed to open a new powershell in order to get the completition.
To be complete (for my own lookup later)
%USERPROFILE%\.dotnet-suggest-registration.txt
executable full path which is registered.
%TEMP%\system-commandline-sentinel-files
sentinel files location, once a file is located here, no new registration is possible.
For Cleanup:
delete .dotnet-suggest-registration.txt
clear directory content system-commandline-sentinel-files
- open a new shell
- call exe with e.g.
-? - open new shell => tab completition works
Damn! Thank you @BobSilent !!! I was just banging my head against a wall wondering WTF?!? I followed your steps and my app now has completion support. This is a pretty bad bug... hopefully it gets prioritized.
A similar scenario: I build a command-line application and run it from the bin/Debug directory. It registers itself with dotnet suggest, and tab completion works in PowerShell. Then I build the Release configuration of the same version and run it from the bin/Release directory. It does not register itself because the assembly name matches the sentinel file that was created for the debug binary. Tab completion does not work.