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

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

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

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

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

手順 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.26100 --log $env:USERPROFILE/Desktop/sdk-install.log

Windows WDK:

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

VS 17.11.0 以降を使用している場合は、インストール拡張機能のチェック ボックスをオフにします。

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

注釈

このセクションは、17.11.0 リリースより前の VS を使用する場合にのみ適用されます。

コマンド ラインから WDK をインストールした後、ドライバーをビルドしてテストできるようにするには、Windows Driver Kit Visual Studio 拡張機能を個別にインストールする必要があります。 既定では、拡張機能は%ProgramFiles(x86)%\Windows Kits\10\Vsix\VS2022\10.0.26100.0\%PROCESSOR_ARCHITECTURE%\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.26100.0\%PROCESSOR_ARCHITECTURE%\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.26100.0\${env:PROCESSOR_ARCHITECTURE}\WDK.vsix"

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

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

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

  • Visual Studio 2022 Community
  • Visual Studio では、ドライバー開発に必要なワークフローとコンポーネントが必要です。
  • Windows 11、 バージョン 24H2 SDK
  • Windows 11、 バージョン 24H2 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://raw.githubusercontent.com/microsoft/Windows-driver-samples/main/configuration.dsc.yaml' -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 エディションをインストールします。 別のエディションが必要な場合は、インストールしたいエディション用の異なる ID で Microsoft.VisualStudio.2022.CommunityMicrosoft.VisualStudio.Product.Community の製品 ID を編集できます (Professionalの場合:Microsoft.VisualStudio.2022.Professional および Microsoft.VisualStudio.Product.Professional;Enterpriseの場合:Microsoft.VisualStudio.2022.Enterprise および Microsoft.VisualStudio.Product.Enterprise)。

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

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

winget configure -f configuration.dsc.yaml

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

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

関連項目