2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【C#】Powershellからdotnetcliのタブ補完を有効にする方法

2
Last updated at Posted at 2026-02-10

dotnet newdotnet add package を使うとき、候補をタブで補完できると入力がかなり楽になります。ここでは PowerShell から dotnet CLI の補完を有効化する手順をまとめます。

手順

PowerShell のプロファイルに次の設定を追加します。.NET 10 以降の場合はこれだけで有効化できます。

# dotnet CLIの補完を有効化
dotnet completions script pwsh | Out-String | Invoke-Expression

文字化けする場合の対策

環境によっては、既定の入出力エンコーディングが Shift-JIS になっており、補完スクリプトの出力が文字化けして失敗することがあります。その場合は、次の設定で入出力を UTF-8 に統一してください。

# 文字コードをUTF8に統一
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::InputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8

最後に

自分の環境だとデフォルトの入出力がShift-JISになっており、その部分の解決に手間取りました。

この記事が皆様のコーディングライフの助けになれば幸いです。

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?