Working containerized build environment

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”]

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.