Building a Driver with the WDK
This topic describes how to build a driver with the Windows Driver Kit (WDK). WDK 10 is fully integrated with Microsoft Visual Studio. You can build a driver using the Visual Studio development environment, or you can build a driver directly from the command line using the Microsoft Build Engine (MSBuild).
You can use any edition of Microsoft Visual Studio 2015 RC, including Microsoft Visual Studio Community 2015 RC, to build drivers for:
- Windows 10 Insider Preview
- Windows 8.1
- Windows 7
You build a driver the same way you build any project or solution in Visual Studio. When you create a new driver project using a Windows driver template, the template defines a default (active) project configuration and a default (active) solution build configuration.
For information about managing and editing build configurations, see Building in Visual Studio.
The default Solution build configuration is Debug and Win32. In versions of the WDK prior to Windows 8, this build configuration would correspond to building a driver using an x86 Checked Build Environment.
To select a configuration and build a driver
- Ensure that you have the same version of SDK and WDK installed on your computer.
- Open the driver project or solution in Visual Studio.
- Right-click the solution in the Solutions Explorer and select Configuration Manager.
- From the Configuration Manager, select the Active Solution Configuration (for example, Debug or Release) and the Active Solution Platform (for example, Win32) that correspond to the type of build you are interested in.
- Select the target operating system for which to build the driver. Navigate to the project properties in Driver > General, and set the TargetVersion property.
- Configure the project properties for your driver or driver package. You can set properties for deployment, driver signing, or other tasks. For more information, see Configuring project properties for your driver and driver package.
- From the Build menu, click Build Solution (Ctrl+Shift+B).
You can build a driver from the command line using the Visual Studio Command Prompt window and the Microsoft Build Engine (MSBuild)
To build a driver using the Visual Studio Command Prompt window
Open a Developer Command Prompt for VS2015 window.
From this window you can use MSBuild.exe to build any Visual Studio project by specifying the project (.VcxProj) or solutions (.Sln) file.
Navigate to the project directory and enter the MSbuild command for your target.
For example, to perform a clean build of a Visual Studio driver project called MyDriver.vcxproj using the default Platform and Configuration, navigate to the project directory and enter the following MSBuild command:
msbuild /t:clean /t:build .\MyDriver.vcxproj
Syntax - To specify a specific configuration and platform, use the following command syntax:
msbuild /t:clean /t:build ProjectFile /p:Configuration=<Debug|Release> /p:Platform=architecture /p:TargetPlatformVersion=a.b.c.d /p:TargetVersion=OS
For example, the following command builds a Universal Windows driver for the "Debug" configuration, "Win32" platform, and for Windows 10 Insider Preview.
msbuild /t:clean /t:build .\MyDriver.vcxproj /p:Configuration="Debug" /p:Platform=Win32 /p:TargetVersion=”Windows10” /p:TargetPlatformVersion=”10.0.10010.0”
The TargetPlatformVersion setting is optional and allows you to specify the kit version to build with. The default is to use the latest kit.
Property pages allow you to configure and set options for your driver and driver package. You can choose to configure your driver so that it is automatically signed when you build your solution, or automatically deployed to a remote test computer.
The WDK provides a number of command-line tools, such as Stampinf and WPP Preprocessor (WPP Tracing), that are commonly included in the build process. These tools are not distributed with Visual Studio. To combine these tools with the Visual Studio build environment they are wrapped as WDK tasks for MSBuild. If you use one of the driver templates or have an existing driver that you have converted, these property pages might already exist for your project. If not, the property pages are automatically added to your project as you add the related file types to the project or solution (for example, .mc or .man files for the message compiler). For more information, see WDK and the Visual Studio build environment
You can set properties for an individual driver or for an entire driver package. The following table shows some of the available properties that you can configure specifically for drivers and driver packages.
|Driver Project Properties||Driver Package Properties|
Signing properties for individual driver files (see Signing a Driver)
Signing properties for driver packages (see Signing a Driver)
|Counters Manifest Preprocessor Properties for Driver Projects (for CTRPP)|
|Driver Model Settings Properties for Driver Projects|
|Message Compiler Properties for Driver Projects|
|Stampinf Properties for Driver Projects|
|WPP Preprocessor (WPP Tracing)|
The following tip can help you to troubleshoot problems when you use the WDK and Visual Studio to build drivers.
To increase the verbosity of the build output using the options in Visual Studio
- Click Tools> Options.
- Click the Project and Solutions folder and click Build and Run.
- Change the options for the MSBuild project build output verbosity and MSBuild project build log file verbosity. By default, these are set to Minimal.
- Building in Visual Studio
- Building Drivers for Different Versions of Windows
- Using the Microsoft C Runtime with User-Mode Drivers and Desktop Apps
- Creating a Driver From Existing Source Files
- WDK and the Visual Studio build environment
- Signing a Driver
- Deploying a Driver to a Test Computer