# escape=` # Based on this guide describing how to create a build tools container # https://learn.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2022 FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-20240213-windowsservercore-ltsc2019 # Restore the default Windows shell for correct batch processing. SHELL ["cmd", "/S", "/C"] RUN ` # Download the Build Tools bootstrapper 17.8.8 # All fixed version releases installers are here: # https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-history#fixed-version-bootstrappers curl -SL --output vs_buildtools.exe https://download.visualstudio.microsoft.com/download/pr/cf977820-7491-4d7f-bd0f-500597f0ea0c/9271cd86da634e354be6035c6aaaffd7c62e458f39410812fcb3f35f4e57d908/vs_BuildTools.exe ` ` # Install visual studio with the specified workloads # List of workloads IDs here: https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-professional?view=vs-2022 && (start /w vs_buildtools.exe --quiet --wait --norestart --nocache ` --installPath "C:\Program Files\Microsoft Visual Studio\2022\BuildTools" ` --add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools ` --add Microsoft.VisualStudio.Workload.WebBuildTools ` --add Microsoft.NetCore.Component.SDK ` # Exclude workloads and components with known issues --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 ` --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 ` --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 ` --remove Microsoft.VisualStudio.Component.Windows81SDK ` --includeRecommended ` || IF "%ERRORLEVEL%"=="3010" EXIT 0) ` ` # Cleanup && del /q vs_buildtools.exe # Disable defender to improve performance RUN powershell -Command "Uninstall-WindowsFeature -Name Windows-Defender" # Some unit tests require the use of fonts, which aren't installed in the base image COPY ./Fonts/*.ttf /Windows/Fonts/ RUN powershell -Command "Get-ChildItem c:\Windows\Fonts\*.ttf | Foreach-Object { ` reg add 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' /v ` \"$([System.IO.Path]::GetFileNameWithoutExtension($_.FullName)) (TrueType)\" /t REG_SZ /d $_.FullName /f ` }" # Copy procdump so it can be used in case of test host crash COPY ./Tools/** /Tools/ # Add tools, msbuild and vstest to PATH env variable COPY ./Scripts/Set-Path.ps1 c:\temp\ RUN powershell -ExecutionPolicy Bypass -File c:\temp\Set-Path.ps1 # Container jobs require cmd as entry point ENTRYPOINT [ "cmd.exe", "/c" ]