LoginSignup
15
15

Wingetについて

Last updated at Posted at 2020-06-17
1 / 19
公式サイト

公式ブログ
https://devblogs.microsoft.com/commandline/windows-package-manager-preview/
公式ヘルプ
https://docs.microsoft.com/ja-jp/windows/package-manager/


概要
  • Microsoft公式のコマンドラインパッケージマネージャーがリリース!(2020年6月2日現在プレビュー版)
  • ソフトウェアの必要な場所からのダウンロードとインストールを自動化できる。
    • 最新バージョン(または指定した正確なバージョン)を検索してインストール
    • search、showコマンドで使用可能なパッケージの検索
  • 新たにパッケージマネージャーを作成した理由
    • 信頼されたアプリケーションのリポジトリを構築し、悪意のあるソフトウェアがリポジトリやマシンに侵入する可能性を減らす。
    • パッケージマネージャーをネイティブWindowsアプリケーションとして提供する。
  • すべてのWindows 10バージョンをサポートしている

便利になること
  • 例えば、Azureのチャットボット開発で、以下のコマンドで基本的な環境がそろう
    • 再インストール、他の方に環境を設定してもらう際も便利になりそう
winget install -e --id Microsoft.PowerShell
winget install -e --id Microsoft.AzureCLI
winget install -e --id Microsoft.WindowsTerminal
winget install -e --id Microsoft.VisualStudioCode
winget install -e --id Microsoft.BotFrameworkEmulator
winget install -e --id Microsoft.BotFrameworkComposer

インストール
Windows 11
  • ✅標準でインストール
Windows 10

使用できるコマンド
install   指定されたアプリケーションをインストール
show      アプリケーションに関する情報を表示
source    アプリケーションのソースを管理
search    アプリの基本情報を見つけて表示
hash      インストーラー ファイルをハッシュするヘルパー
validate  マニフェスト ファイルを検証

install オプション(--help
-m,--manifest     アプリケーションのマニフェストへのパス
--id              ID で結果をフィルター処理
--name            名前で結果をフィルター処理
--moniker         アプリ モニカーで結果をフィルター処理
-v,--version      指定されたバージョンを使用します。既定値は最新のバージョンです
-s,--source       指定されたリソースを使用してアプリを検索
-e,--exact        完全一致を使用してアプリを検索
-i,--interactive  対話式インストールを要求する;ユーザー入力が必要である可能性があります
-h,--silent       サイレント インストールを要求
-o,--log          ログの場所 (サポートされている場合)
--override        インストーラーに渡される引数を上書き
-l,--location     インストール先 (サポートされている場合)

More help can be found at: https://aka.ms/winget-command-install

install

  • 既定では対話型モードではないが、インストールの進行状況が表示される。
1. 複数候補がある場合は、失敗する。
> winget install PowerShell
Multiple apps found matching input criteria. Please refine the input.
Name                     Id                               Version         Matched
-----------------------------------------------------------------------------------------
PowerShell               Microsoft.PowerShell             7.0.2
Windows Terminal Preview Microsoft.WindowsTerminalPreview 1.0.1401.0      Tag: PowerShell
PowerShell-Preview       Microsoft.PowerShell-Preview     7.1.0-preview.3
Windows Terminal         Microsoft.WindowsTerminal        1.0.1401.0      Tag: powershell
2. IDでの完全一致指定を行う場合は-e--idを付加する
winget install -e --id Microsoft.PowerShell

serch, show オプション(--help

https://docs.microsoft.com/ja-jp/windows/package-manager/winget/search
https://docs.microsoft.com/ja-jp/windows/package-manager/winget/show

ほぼ同じオプション。

以下が共通

  --id         ID で結果をフィルター処理
  --name       名前で結果をフィルター処理
  --moniker    アプリ モニカーで結果をフィルター処理
  -s,--source  指定されたリソースを使用してアプリを検索
  -e,--exact   完全一致を使用してアプリを検索

search 固有オプション
  --tag        タグ で結果をフィルター処理
  --command    コマンドによる結果のフィルター処理
  -n,--count   指定した数以下の結果を表示

show 固有オプション
  -m,--manifest  アプリケーションのマニフェストへのパス
  -v,--version   指定されたバージョンを使用します。既定値は最新のバージョンです
  --versions     アプリの利用可能なバージョンを表示

source

  • 追加のソースは、現時点ではサポートされていません。

wingetでダウンロード中のファイルが配置される場所
%USERPROFILE%\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\

うまくいかない場合その1(権限がない場合)
1. 通常権限で実行
winget install --Id OpenJS.Nodejs
Found Node.js [OpenJS.Nodejs]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://nodejs.org/dist/v14.4.0/node-v14.4.0-x64.msi
  ██████████████████████████████  28.7 MB / 28.7 MB
Successfully verified installer hash
Installing ...
  • エラーコードが返却され、実行できない。
  • 対処策:管理者権限でコマンドを実行する。
Installer failed with exit code: 1602
Installer log is available at: C:\Users\\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\TempState\WinGet\OpenJS.Nodejs.14.4.0.log
2. 管理者で実行
Found Node.js [OpenJS.Nodejs]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://nodejs.org/dist/v14.4.0/node-v14.4.0-x64.msi
  ██████████████████████████████  28.7 MB / 28.7 MB
Successfully verified installer hash
Installing ...
Successfully installed!

うまくいかない場合その2(英語版と日本語版)
winget install Microsoft.SQLServerManagementStudio
Found SQL Server Management Studio [Microsoft.SQLServerManagementStudio]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://go.microsoft.com/fwlink/?linkid=2125901&clcid=0x409
  ██████████████████████████████  534 MB /  534 MB
Successfully verified installer hash
Installing ...
Installer failed with exit code: 1626
  • Microsoft SQL Server Mangement Studioは、既定でインストールされるのが英語版
  • 日本語版インストール済環境に英語版をインストールしてもバージョンアップできない
  • ログを確認しないと詳細はわからなかった。
    • %USERPROFILE%\AppData\Local\Temp\SsmsSetup\SSMS-Setup-ENU_20200609110102.log
  • 日本語版をアンインストールすれば英語版をインストールできるが、当然ながら英語版しか使えない(SSMSは英語版と日本語版が別インストーラー)
  • 日本語版を使いたければ、SSMSは通常通りのインストールとなる

うまくいかない場合その3(同一バージョン)
  • 同一バージョンの場合には、エラーコードが返却されたことがあった。(インストーラー次第)

うまくいかない場合その4(自分自身の更新)
  • Windows Terminal上のPoweshellからPoweshellをインストールするとエラーとなったことがあった(自分自身を更新しようとしたため?)
    • cmd.exeから再インストールすると復旧した。

補足
  • 管理者のコマンドプロンプトから起動しなかった場合は、UACでブロックされる。
  • wingetのリポジトリは反映が遅い場合があった。
    • PowerShellのコマンドで、PoweShellが古いというメッセージが表示されるが、wingetではまだ更新されていないことがあった。

参考
15
15
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
15
15