Announcing the WDK NuGet: A New Way to Develop Drivers on WIndows

As far as I am concerned, the 'Nuget Package Manager' in visual studio is useless and should be avoided.

Here is what works for me, and is what Microsoft is also doing for building their driver samples on github.

At the root directory (where the solution file is) you should have a packages.config file, a packages directory, and a directory.build.props file.

packages.config:

<?xml version="1.0" encoding="utf-16"?>
<packages>
  <package id="Microsoft.Windows.SDK.CPP" version="10.0.26100.3323" targetFramework="native" />
  <package id="Microsoft.Windows.SDK.CPP.x64" version="10.0.26100.3323" targetFramework="native" />
  <package id="Microsoft.Windows.SDK.CPP.arm64" version="10.0.26100.3323" targetFramework="native" />
  <package id="Microsoft.Windows.WDK.x64" version="10.0.26100.3323" targetFramework="native" />
  <package id="Microsoft.Windows.WDK.arm64" version="10.0.26100.3323" targetFramework="native" />
</packages>

directory.build.props:

<Project> 

<Import Project="packages\Microsoft.Windows.WDK.x64.10.0.26100.3323\build\native\Microsoft.Windows.WDK.x64.props" 
    Condition="Exists('packages\Microsoft.Windows.WDK.x64.10.0.26100.3323\build\native\Microsoft.Windows.WDK.x64.props') and '$(Platform)' == 'x64'"/> 

<Import Project="packages\Microsoft.Windows.WDK.arm64.10.0.26100.3323\build\native\Microsoft.Windows.WDK.arm64.props" 
    Condition="Exists('packages\Microsoft.Windows.WDK.arm64.10.0.26100.3323\build\native\Microsoft.Windows.WDK.arm64.props') and '$(Platform)' == 'ARM64'"/>

<Import Project="packages\Microsoft.Windows.SDK.CPP.x64.10.0.26100.3323\build\native\Microsoft.Windows.SDK.cpp.x64.props" 
    Condition="Exists('packages\Microsoft.Windows.SDK.CPP.x64.10.0.26100.3323\build\native\Microsoft.Windows.SDK.cpp.x64.props') and '$(Platform)' == 'x64'"/> 
    
<Import Project="packages\Microsoft.Windows.SDK.CPP.arm64.10.0.26100.3323\build\native\Microsoft.Windows.SDK.cpp.arm64.props" 
    Condition="Exists('packages\Microsoft.Windows.SDK.CPP.arm64.10.0.26100.3323\build\native\Microsoft.Windows.SDK.cpp.arm64.props') and '$(Platform)' == 'ARM64'"/>

<Import Project="packages\Microsoft.Windows.SDK.CPP.10.0.26100.3323\build\native\Microsoft.Windows.SDK.cpp.props" 
    Condition="Exists('packages\Microsoft.Windows.SDK.CPP.10.0.26100.3323\build\native\Microsoft.Windows.SDK.cpp.props')"/> 

</Project>

The directory.build.props file will add the associated nuget packages to all projects without having to individually modify each project.

To populate the packages directory, use nuget.exe. (You will have to install nuget.exe by downloading it from nuget.org, or by using winget, chocolatey, scoop etc. For unknown reasons Microsoft refuses to include it as a standard build tool.)

nuget restore .\packages.config -PackagesDirectory .\packages\

You should only have to do a restore once, unless you change the versions you are using. (For an automated build system the restore should be done as part of the setup for the build.)

4 Likes