Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Working containerized build environment

Heath_CarrollHeath_Carroll Member Posts: 1

As a continuation from a previous thread on the forum (https://community.osr.com/discussion/comment/289437), here is a dockerfile that encapsulates all the tools we need for our toolchain (.NET 4.5.2, sdk/wdk 10.0.19041). It uses Windows Server Core 2022 and the Visual Studio 2019 buildtools.
I'm horrible at responding to forum posts, but I'll try to be better at it for the next week or so.

# escape=`
# build: docker build --tag <image-tag> -m 3GB .
# run: docker run -it <image-tag>

# Use the latest Windows Server Core 2022 image.
FROM mcr.microsoft.com/windows/servercore:ltsc2022

LABEL Author="Heath Carroll"
LABEL BaseImage="servercore:ltsc2022"

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

# Install Chocolatey
RUN powershell -NoProfile -ExecutionPolicy Bypass -Command "$env:ChocolateyUseWindowsCompression='false'; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

# Install VS2019 buildtools
# Our solution has C, C++, and C# projects, and requires Spectre enabled AFL and MFC libraries.
# Change "Microsoft.Net.Component.4.5.2.TargetingPack" below to match .NET version used.
RUN choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre --add Microsoft.VisualStudio.Component.VC.ATL.Spectre --add Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre --add Microsoft.Net.Component.4.5.2.TargetingPack" --execution-timeout 30000 -y
RUN choco install windows-sdk-10-version-2004-all --version=10.0.19041.0 -y
RUN choco install windowsdriverkit10 -y
RUN choco install visualstudio2019-workload-visualstudioextensionbuildtools --package-parameters "--includeOptional" -y

# Fix VS2019 extension WDK location
# Avoids "error MSB8020: The build tools for WindowsKernelModeDriver10.0 cannot be found."
# Workaround found here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/e6fa261a-4cc7-422d-a2d9-a5ed7b7c69e2/error-msb8020-the-build-tools-for-windowskernelmodedriver100-cannot-be-found
RUN powershell -NoProfile -ExecutionPolicy Bypass -Command "Copy-Item 'C:\Program Files (x86)\Windows Kits\10\Vsix\VS2019\WDK.vsix' 'C:\wdkvsix.zip'; Expand-Archive 'C:\wdkvsix.zip' -DestinationPath 'C:\WdkVsix'; Copy-Item 'C:\WdkVsix\$MSBuild\Microsoft\*' -Destination 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft' -Recurse -Force; Remove-Item 'C:\WdkVsix' -Force -Recurse; Remove-Item 'C:\wdkvsix.zip' -Force"

# Start developer command prompt with any other commands specified.
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "pwsh.exe"]

Comments

  • Phil_BarilaPhil_Barila Member - All Emails Posts: 165

    That's sick! Thanks!
    The last statement assigning it pwsh as the entrypoint doesn't work, though, as pwsh is never installed.
    Easy enough to either end it with cmd.exe or add the choco install pwsh -y. I added pwsh.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Internals & Software Drivers 19-23 June 2023 Live, Online
Writing WDF Drivers 10-14 July 2023 Live, Online
Kernel Debugging 16-20 October 2023 Live, Online
Developing Minifilters 13-17 November 2023 Live, Online