Building a Driver with the WDK

Build a driver with the Windows Driver Kit (WDK). WDK 8 and WDK 8.1 are 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). To build drivers for Windows 8.1, Windows 8, Windows 7, and Windows Vista, use Visual Studio and MSBuild. To build drivers for Windows XP, you must use the Windows 7 WDK and the Windows Build Utility (Build.exe).

Important  MSBuild replaces the Windows Build Utility (Build.exe) that was used in previous versions of the WDK. The WDK now uses the same compiler and build tools that you use to build Visual Studio projects. Driver projects that were built with previous versions of the WDK must be converted to work in the Visual Studio environment. You can run a conversion utility from the command line, or you can convert an existing driver by creating new Visual Studio project from existing sources. For more information, see Creating a Driver From Existing Source Files and WDK and the Visual Studio build environment.

This section describes the following:

Building a Driver Using Visual Studio

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.

Note  Projects and solutions created with the Windows Driver Kit (WDK) 8 must be upgraded to work with the WDK for Windows 8.1 and Microsoft Visual Studio 2013. Before you open the projects or solutions, run the ProjectUpgradeTool. The ProjectUpgradeTool converts the projects and solutions so that they can be built using WDK 8.1.

For information about managing and editing build configurations, see Building in Visual Studio.

Selecting the Solution build configuration, setting options, and building a driver

The default Solution build configuration is Win8 Debug and Win32. In previous versions of the WDK, this build configuration would correspond to building a driver using an x86 Checked Build Environment.

Ff554644.wedge(en-us,VS.85).gifTo select a configuration and build a driver

  1. Open the driver project or solution in Visual Studio.
  2. Right-click the solution in the Solutions Explorer and select Configuration Manager.
  3. From the Configuration Manager, select the Active Solution Configuration (for example, Win8 Debug or Win8 Release) and the Active Solution Platform (for example, Win32) that correspond to the type of build you are interested in.
  4. 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.
  5. From the Build menu, click Build Solution (Ctrl+Shift+B).

Building a Driver Using the Command Line (MSBuild)

You can build a driver from the command line using the Visual Studio Command Prompt window and the Microsoft Build Engine (MSBuild) Previous versions of the WDK used the Windows Build utility (Build.exe) and provided separate build environment windows for each of the supported build configurations. You can now use the Visual Studio Command Prompt window for all build configurations.

Ff554644.wedge(en-us,VS.85).gifTo build a driver using the Visual Studio Command Prompt window

  1. Open a Visual Studio Command Prompt window.

    From this window you can use MSBuild.exe to build any Visual Studio project by specifying the project (.VcxProj) or solutions (.Sln) file.

  2. 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=configuration /p:Platform=platform     
    
    
    

    For example, the following command builds a driver for the "Win8 Debug" configuration and "Win32" platform:

    msbuild /t:clean /t:build .\MyDriver.vcxproj /p:Configuration="Win8 Debug" /p:Platform=Win32
    

WDK Project Build Configurations in Visual Studio

The following table shows how the Project Build Configurations in Visual Studio correspond to the Build Environments that were used in previous versions of the WDK (prior to WDK 8).

Important  To build drivers for Windows XP or to build drivers for ia64-based computers, you must use the Windows 7 WDK. You can download the Windows 7 WDK from the Windows Dev Center - Hardware site. To build drivers for Windows Vista, you must use the WDK 8 or WDK 7.

Project ConfigurationProject PlatformEquivalent Windows 7 WDK Build Environment Window

Win8.1 Debug

Win32, x64, or ARM

Not available in Windows 7 WDK or WDK 8

Win8.1 Release

Win32, x64, or ARM

Not available in Windows 7 WDK or WDK 8

Win8 Debug

Win32 or x64

Not available in Windows 7 WDK

Win8 Release

Win32 or x64

Not available in Windows 7 WDK

Win7 Debug

Win32

Win7 x86 Checked Build

Win7 Release

Win32

Win7 x86 Free Build

Win7 Debug

x64

Win7 x64 Checked Build

Win7 Release

x64

Win7 x64 Free Build

Vista Debug

Not available in WDK 8.1

Win32

Vista x86 Checked Build

Vista Release

Not available in WDK 8.1

Win32

Vista x86 Free Build

Vista Debug

Not available in WDK 8.1.

x64

Vista x64 Checked Build

Vista Release

Not available in WDK 8.1.

x64

Vista x64 Free Build

 

Configuring project properties for your driver and driver package

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 PropertiesDriver 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)

Deployment Properties for Driver Package Projects (see Deploying a Driver to a Test Computer)

Driver Model Settings Properties for Driver Projects

Driver Verifier Properties for Driver Package Projects

Message Compiler Properties for Driver Projects

KMDF Verifier Properties for Driver Package Projects

Stampinf Properties for Driver Projects

UMDF Verifier Properties for Driver Package Projects

WPP Preprocessor (WPP Tracing)

Inf2Cat Properties for Driver Package Projects (see the Inf2Cat tool)

 

Troubleshooting tip for building a driver

The following tip can help you to troubleshoot problems when you use the WDK and Visual Studio to build drivers.

Ff554644.wedge(en-us,VS.85).gifTo increase the verbosity of the build output using the options in Visual Studio

  1. Click Tools> Options.
  2. Click the Project and Solutions folder and click Build and Run.
  3. Change the options for the MSBuild project build output verbosity and MSBuild project build log file verbosity. By default, these are set to Minimal.

Related topics

Building in Visual Studio
ProjectUpgradeTool
MSBuild
Creating a Driver From Existing Source Files
WDK and the Visual Studio build environment
Signing a Driver
Deploying a Driver to a Test Computer

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft