• .NET
  • PowerShell
  • Code Snippet

Enable .NET CLI Tab Completion

Below is a PowerShell snippet you can use to enable tab completion for the .NET CLI! Put this snippet into a PowerShell Profile, load it on startup and enable tab completion for your .NET commands.

# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
     param($commandName, $wordToComplete, $cursorPosition)
         dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
            [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
         }
 }
This image shows the dotnet tab completion in action by highlighting '--version' and a list of other commands that can be selected.

Reference

You can read more on How to enable TAB completion for the .NET CLI where they also give code snippets to enable tab completion across multiple shells.

Cody's logo image, it is an abstract of a black hole with a white Event Horizon.

Cody Merritt Anhorn

A Engineer with a passion for Platform Architecture and Tool Development.