WinGet を使用して WDK をインストールする

Windows パッケージ マネージャー (WinGet) ツールを使用して、コンピューターに Windows ドライバー キットをインストールまたは更新し、Visual Studio や Windows ソフトウェア開発キットなどの依存関係をすべてコマンド ラインからインストールまたは更新できます。

WinGet が正しくインストールされ、構成されていることを確認するためにヘルプが必要な場合は、「WinGet のインストールに関するドキュメント」 を参照してください。

WinGet を使用して最新の WDK を段階的にインストールする

Azure WDK の最新バージョンは 10.0.22621 です。 Visual Studio 2022 と Windows SDK 10.0.22621 が必要です。 詳細については、キット バージョン管理に関する記事を参照してください。

手順 1: Visual Studio 2022 のインストール

WDK には、Visual Studio 2022 と C++ ワークロードがインストールされたデスクトップ開発、 VS 2022 C++ ビルド ツール 、およびドライバーをビルドするアーキテクチャごとに対応する VS 2022 C++ Spectre 軽減ライブラリ (最新) コンポーネントが必要です。

WinGet を使用して、ドライバー開発に必要なすべてのワークロードとコンポーネントを含む Visual Studio 2022 をインストールできます。 そのためには、Visual Studio のインストール構成ファイルが必要です。 次の内容の wdk.vsconfig ファイルを作成し、その場所を書き留めます。

{
  "version": "1.0",
  "components": [
    "Microsoft.Component.MSBuild",
    "Microsoft.VisualStudio.Component.CoreEditor",
    "Microsoft.VisualStudio.Component.NuGet",
    "Microsoft.VisualStudio.Component.Roslyn.Compiler",
    "Microsoft.VisualStudio.Component.TextTemplating",
    "Microsoft.VisualStudio.Component.VC.ASAN",
    "Microsoft.VisualStudio.Component.VC.ATL.ARM64.Spectre",
    "Microsoft.VisualStudio.Component.VC.ATL.ARM64",
    "Microsoft.VisualStudio.Component.VC.ATL.Spectre",
    "Microsoft.VisualStudio.Component.VC.ATL",
    "Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre",
    "Microsoft.VisualStudio.Component.VC.ATLMFC",
    "Microsoft.VisualStudio.Component.VC.CoreIde",
    "Microsoft.VisualStudio.Component.VC.MFC.ARM64.Spectre",
    "Microsoft.VisualStudio.Component.VC.MFC.ARM64",
    "Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
    "Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre",
    "Microsoft.VisualStudio.Component.VC.Runtimes.ARM64EC.Spectre",
    "Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre",
    "Microsoft.VisualStudio.Component.VC.Tools.ARM64",
    "Microsoft.VisualStudio.Component.VC.Tools.ARM64EC",
    "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
    "Microsoft.VisualStudio.Component.Windows10SDK",
    "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
    "Microsoft.VisualStudio.Workload.CoreEditor",
    "Microsoft.VisualStudio.Workload.NativeDesktop"
  ]
}

インストールするエディションに応じて、インストールをカスタマイズするために作成した .vsconfig ファイルへのパスと共に、別のインストーラー パラメーターセットを指定 winget する必要があります。

注意

次のコマンドでは、ファイルへの wdk.vsconfig 絶対パスを指定する必要があります。 それ以外の場合、WinGet は成功を報告しながら Visual Studio のインストールに失敗する可能性があります。

Visual Studio Community 2022:

winget install --source winget --exact --id Microsoft.VisualStudio.2022.Community --override "--passive --config <vsconfig-folder>\wdk.vsconfig"

Visual Studio Professional 2022:

winget install --source winget --exact --id Microsoft.VisualStudio.2022.Professional --override "--passive --config <vsconfig-folder>\wdk.vsconfig""

Visual Studio Enterprise 2022:

winget install --source winget --exact --id Microsoft.VisualStudio.2022.Enterprise --override "--passive --config <vsconfig-folder>\wdk.vsconfig"

詳細については、WinGet を使用して Visual Studio をインストールまたは変更する方法 に関する Visual Studioのドキュメントをチェックできます。

手順 2: Windows SDK および WDK をインストールする

WinGet から Windows SDK と WDK の両方をインストールするには、次のコマンドを実行します。

Windows SDK:

winget install --source winget --exact --id Microsoft.WindowsSDK.10.0.22621 --log $env:USERPROFILE/Desktop/sdk-install.log

Windows WDK:

winget install --source winget --exact --id Microsoft.WindowsWDK.10.0.22621 --log $env:USERPROFILE/Desktop/wdk-install.log

手順 3:WDK Visual Studio Code 拡張機能をインストールする

コマンド ラインから WDK をインストールした後、ドライバーをビルドおよびテストできるようにするには、Windows Driver Kit Visual Studio 拡張機能を個別にインストールする必要があります。 既定では、拡張機能は 〘 の下 %ProgramFiles(x86)%\Windows Kits\10\Vsix\VS2022\10.0.22621.0\WDK.vsixにあります。

コマンド プロンプトを使用:

for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -nologo -latest -products * -property enginePath`) do (
  "%i\VSIXInstaller.exe" "%ProgramFiles(x86)%\Windows Kits\10\Vsix\VS2022\10.0.22621.0\WDK.vsix"
)

PowerShell の使用:

& $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -nologo -latest -products * -property enginePath | Join-Path -ChildPath 'VSIXInstaller.exe') "${env:ProgramFiles(x86)}\Windows Kits\10\Vsix\VS2022\10.0.22621.0\WDK.vsix"

WinGet を使用して他の WDK バージョンをインストールする

WinGet からさまざまな Windows バージョンの複数のキットをインストールできます。

Note

バージョン 22000 (Windows 11 バージョン 21H2 を対象とする) 以前の場合は、以前のバージョンの Visual Studio をインストールする必要があります。 「その他の WDK ダウンロード>手順 1: Visual Studio をインストールして、インストールする WDK バージョンに必要な Visual Studio バージョンを見つける」を参照してください。

このコマンドを使用して、使用可能な他のキット バージョンを winget search 検索できます。

Windows SDK:

winget search --source winget --id Microsoft.WindowsSDK

Windows WDK:

winget search --source winget --id Microsoft.WindowsWDK

各コマンドは、WinGet で使用可能なすべての SDK/WDK バージョンを含むテーブルを返します。 たとえば、使用可能なすべての WDK バージョンを探すと、次のようなテーブルが表示されます。

Name                                        Id                              Version        Source
--------------------------------------------------------------------------------------------------
Windows Driver Kit - Windows 10.1.22000.1   Microsoft.WindowsWDK.10.0.22000 10.1.22000.1   winget
Windows Driver Kit                          Microsoft.WindowsWDK.10.0.19041 10.1.19041.685 winget
Windows Driver Kit - Windows 10.0.22621.382 Microsoft.WindowsWDK.10.0.22621 10.1.22621.382 winget

その後、次のコマンドを使用して、<kit-version>特定winget installのキットの必要な組み合わせをインストールできます。

Windows SDK:

winget install --source winget --exact --id Microsoft.WindowsSDK.10.0.<kit-version>

Windows WDK:

winget install --source winget --exact --id Microsoft.WindowsWDK.10.0.<kit-version>

Note

お探しの Windows Driver Kit のバージョンが WinGet で利用できない場合は、 他の WDKダウンロードとは別にダウンロードしてインストールする必要があります。

新しい WDK の WDK Visual Studio 拡張機能が既にインストールされていない限り、手動でインストールする必要があります。 既定では、キット バージョン 22621 以降、または%ProgramFiles(x86)%\Windows Kits\10\Vsix\<vs-version>\10.0.<kit-version>.0\WDK.vsixキット バージョン 22000 以前の場合に配置されます%ProgramFiles(x86)%\Windows Kits\10\Vsix\<vs-version>\WDK.vsix

使用するフォルダー <vs-version> を最初に見つけます (VS2022 バージョン 22621 以降、 VS2019 バージョン 18362 から 22000)。 そのフォルダーに複数のバージョン管理されたフォルダーが含まれている場合は、最新のバージョン番号で内部のフォルダーを見つけます。 コマンド ラインから拡張機能をインストールする場合と同様に、 <wdk-vsix-folder> この場所を書き留めます。

コマンド プロンプトを使用:

for /f "usebackq tokens=*" %i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -nologo -latest -products * -property enginePath`) do (
  "%i\VSIXInstaller.exe" "<wdk-vsix-folder>\WDK.vsix"
)

PowerShell の使用:

& $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -nologo -latest -products * -property enginePath | Join-Path -ChildPath 'VSIXInstaller.exe') "<wdk-vsix-folder>\WDK.vsix"

WinGet 構成ファイルを使用して完全なドライバー開発環境をインストールする

WinGet 構成ファイルを使用すると、最小限の手動介入でドライバー開発用の新しいマシンを設定できます。

Windows 11 バージョン 22H2 WDK とその依存関係をインストールするための構成ファイルが用意されています。 この構成では、次のコンポーネントが設定されます。

  • Visual Studio 2022 Community
  • Visual Studio では、ドライバー開発に必要なワークフローとコンポーネントが必要です。
  • Windows 11、 バージョン 22H2 SDK
  • Windows 11、 バージョン 22H2 WDK
  • WDK Visual Studio 拡張機能

構成記述ファイルを使用すると新しいマシンのプロビジョニングに適していますが、一部のコンポーネントが既にインストールされていて、WinGet が不足しているコンポーネントのインストールのみを試みる場合でも使用できます。

ヒント

PowerShell を使用して、WDK 構成ファイルを直接ダウンロードしてインストールできます。 最新バージョンの WinGet をインストールしたら、次のコマンドを実行できます。

# Open a new PowerShell terminal if needed
powershell

# Download configuration file to install WDK with VS 2022 Community
Invoke-WebRequest -Uri 'https://aka.ms/wdk_winget_config_22621' -OutFile configuration.dsc.yaml

# Install VS, SDK, WDK and WDK VS extension using the configuration file
winget configure -f configuration.dsc.yaml

手順 1: WinGet を設定する

プロビジョニングするマシンに WinGet バージョン 1.6 以降がインストールされていることを確認します。 これを行うには、ターミナルで実行し、winget --version出力バージョン番号v1.6.2631以上であることをチェックします。 そうでない場合、またはコマンドが存在しないことを示すエラーがターミナルからスローされた場合は、続行する前に 最新バージョンのWinGet をインストールする必要があります。

手順 2: WDK 構成ファイルをダウンロードする

構成記述ファイルはここからダウンロードできます。 このファイルを名前を付けて configuration.dsc.yml 保存し、その場所をメモしておきます。

ヒント

指定された構成ファイルによって、Visual Studio 2022 の Community エディションがインストールされます。 別のエディションが必要な場合は、Microsoft.VisualStudio.2022.Communityインストールするエディションの ID が異なる ID を編集してMicrosoft.VisualStudio.Product.Community製品 ID を作成できます (Professional: Microsoft.VisualStudio.2022.Professional および Microsoft.VisualStudio.Product.Professional; for Enterprise: Microsoft.VisualStudio.2022.Enterprise and Microsoft.VisualStudio.Product.Enterprise)。

手順 3A: WinGet 構成を実行して WDK 構成ファイルをインストールする

WDK 構成ファイルが保存されたディレクトリの下のコマンド ラインで、次のコマンドを実行して、そのファイルを使用してコンピューターを構成します。

winget configure -f configuration.dsc.yaml

手順 3B: Dev Home を使用して WDK 構成ファイルをインストールする

または、 Dev Homeがインストールされている場合は、それを使用してマシンを構成できます。 サイドバーから「マシン構成」を選択し、メイン画面で「開発環境をセットアップする」 > 「構成ファイル」を選択して、ダウンロードしたWDK構成ファイルを開きます。 そのファイルを使用してマシンを構成することを確認した後に、インストールが続行され、完了すると、ドライバー開発の環境が整います。

関連項目