Automatically deploying drivers from VisualStudio

  • How to automatically deploy drivers for Debugging

    To facilitate Driver development for for your F&S Single Board Computer (SBC) / System on Module (SoM) running Windows 10 IoT, fast deployment is essential. When using VisualStudio 2019 for driver development, the official Guide for Provisioning a target computer recommends using WDK Test Target Setup (WDK-TTS).
    This guide provides a workaround if WDK-TTS does not run on your SBC or SOM.

    From here on the guide will refer to the SBC or SOM that drivers are developed for as 'board'.

    Creating a shared folder on the board

    If you have not already, follow the steps outlined in "Configuration of SBC/SoM" in our "Deploying & Debugging Visual Studio applications over Ethernet"-Guide

    After following the steps from above, you should have a folder accessible via network on your board. This guide uses \\DESKTOP-1234567\debug located at C:\debug as an example.

    Setting up the board

    1) Download Microsoft's "devcon"-tool

    Download Devcon.exe directly from Microsoft. See…re/drivers/devtest/devcon for instructions.
    Copy devcon.exe to your shared folder.

    2) Download
    Download from here: Extract its contents and place them in the shared folder.

    Your shared folder should now contain

    • devcon.exe
    • auto-driver-reinstaller.ps1
    • run-auto-driver-installer.lnk

    3) Configure auto-driver-reinstaller.ps1 for your driver

    Open auto-driver-reinstaller.ps1 in an editor and find these lines:

    Code: auto-driver-reinstaller.ps1
    1. # USER: Adjust these parameters to fit your Driver!
    2. $drivername = "KFKMDFHelloWorldDriver.inf"
    3. $driverpath = "Root\KFKMDFHelloWorldDriver"
    4. $watchpath = "C:\debug"
    • $watchpath is the path of your shared folder, where your driver-files will be copied to
    • $drivername is the name of the .inf-file of your driver
    • and $driverpath is the HardwareID of the device your driver is targeting. See HardwareID on

    Edit these Lines to fit your driver and shared folder path.

    4) Edit run-auto-driver-installer.lnk

    Right click on the run-auto-driver-installer.lnk-file and ensure it points to auto-driver-reinstaller.ps1. Also check that the working directory is set to the shared folder.

    Refer to this image for an example.

    Enabling deployment from Visual Studio

    1) Configure VisualStudio to copy driver files to your board

    In VisualStudio select your Project in "Solution Explorer".

    Right click, then select "Properties". Navigate to "Configuration Properties" -> "Build Events" -> "Post-Build Event".

    Change Command Line to: xcopy /y "$(PackageDir)" "\\DESKTOP-1234567\debug"
    Confirm by clicking on "OK".

    If no/incorrect driver files are copied try changing the command above to: xcopy /y "$(OutDir)" "\\DESKTOP-1234567\debug"

    This will cause VisualStudio to execute the xcopy command at the end of each build.

    Note: this is only run when a build is executed. Using the "Deploy Project" options provided by VisualStudio is independent of this and will not work.

    2) (Optional) Disable deployment build step

    In VisualStudio select your Solution in "Solution Explorer". Right click, then select "Properties".

    Select "Configuration Properties", then in the "Project"-Pane find your Project.

    Click on the checkbox in the "Deploy" column to remove the checkmark.

    This disables VisualStudios builtin deployment which would require a working "WDK Test Target Setup".

    3) Verify that the files are actually copied to the board

    In VisualStudio click on "Build Solution" to build and copy your driver. The output windows will show a line at the end saying: "3 file(s) copied."

    Check if your shared folder contains the driver files. Look for .sys, .cat and .inf files:

    4) Run auto-driver-reinstaller.ps1 on your board

    Connect to your board via Remote Desktop. Open file explorer, navigate to your shared folder and double click run-auto-driver-installer.lnk.

    Confirm the administrator prompt.

    A Powershell window will open.

    Wait a few seconds for some text to appear inside the powershell window.

    You can now Select Build from VisualStudio and the powershell script will detect that the driver files were changed. It will then reinstall your driver.

    With these steps completed you should now be able to develop your drivers more efficiently. Well Done:thumbsup: