|
| 1 | +# escape=` |
| 2 | + |
| 3 | +ARG REPO=mcr.microsoft.com/dotnet/framework/runtime |
| 4 | +FROM $REPO:4.8.1-20251014-windowsservercore-ltsc2025 |
| 5 | + |
| 6 | +ENV ` |
| 7 | + # Do not generate certificate |
| 8 | + DOTNET_GENERATE_ASPNET_CERTIFICATE=false ` |
| 9 | + # Enable correct mode for dotnet watch (only mode supported in a container) |
| 10 | + DOTNET_USE_POLLING_FILE_WATCHER=true ` |
| 11 | + # NuGet version to install |
| 12 | + NUGET_VERSION=6.14.0 ` |
| 13 | + # Install location of Roslyn |
| 14 | + ROSLYN_COMPILER_LOCATION="C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\Roslyn" |
| 15 | + |
| 16 | +# Install NuGet CLI |
| 17 | +RUN mkdir "%ProgramFiles%\NuGet\latest" ` |
| 18 | + && curl -fSLo "%ProgramFiles%\NuGet\nuget.exe" https://dist.nuget.org/win-x86-commandline/v%NUGET_VERSION%/nuget.exe ` |
| 19 | + && mklink "%ProgramFiles%\NuGet\latest\nuget.exe" "%ProgramFiles%\NuGet\nuget.exe" |
| 20 | + |
| 21 | +# Install VS components |
| 22 | +RUN ` |
| 23 | + # Install VS Build Tools |
| 24 | + curl -fSLo vs_BuildTools.exe https://aka.ms/vs/stable/vs_BuildTools.exe ` |
| 25 | + && start /w vs_BuildTools ^ ` |
| 26 | + --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\18\BuildTools" ^ ` |
| 27 | + --add Microsoft.Component.ClickOnce.MSBuild ^ ` |
| 28 | + --add Microsoft.Net.Component.4.8.1.SDK ^ ` |
| 29 | + --add Microsoft.NetCore.Component.Runtime.8.0 ^ ` |
| 30 | + --add Microsoft.NetCore.Component.Runtime.9.0 ^ ` |
| 31 | + --add Microsoft.NetCore.Component.SDK ^ ` |
| 32 | + --add Microsoft.VisualStudio.Component.NuGet.BuildTools ^ ` |
| 33 | + --add Microsoft.VisualStudio.Component.WebDeploy ^ ` |
| 34 | + --add Microsoft.VisualStudio.Web.BuildTools.ComponentGroup ^ ` |
| 35 | + --add Microsoft.VisualStudio.Workload.MSBuildTools ^ ` |
| 36 | + --quiet --norestart --nocache --wait ` |
| 37 | + && powershell -Command "if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { throw $err }" ` |
| 38 | + && del vs_BuildTools.exe ` |
| 39 | + ` |
| 40 | + # Trigger dotnet first run experience by running arbitrary cmd |
| 41 | + && "%ProgramFiles%\dotnet\dotnet" help |
| 42 | + |
| 43 | + # Workaround for issues with 64-bit ngen |
| 44 | + # && %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen uninstall "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8.1 Tools\SecAnnotate.exe" ` |
| 45 | + # && %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen uninstall "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8.1 Tools\WinMDExp.exe" ` |
| 46 | + ` |
| 47 | + # ngen assemblies queued by VS installers |
| 48 | + # && %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen update ` |
| 49 | + ` |
| 50 | + # Cleanup |
| 51 | + # List all files under Installer directory to help debug |
| 52 | +RUN (for /D %i in ("%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\*") do rmdir /S /Q "%i") ` |
| 53 | + && (for %i in ("%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\*") do if not "%~nxi" == "vswhere.exe" del "%~i") ` |
| 54 | + && powershell -c "Get-ChildItem -Force -Recurse $Env:TEMP" ` |
| 55 | + && powershell -c "Get-ChildItem -Force -Recurse $Env:TEMP | Remove-Item -Force -Recurse" ` |
| 56 | + && rmdir /S /Q "%ProgramData%\Package Cache" |
| 57 | + |
| 58 | +# Set PATH in one layer to keep image size down. |
| 59 | +RUN powershell setx /M PATH $(${Env:PATH} ` |
| 60 | + + \";${Env:ProgramFiles}\NuGet\" ` |
| 61 | + + \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\18\BuildTools\MSBuild\Current\Bin\amd64\" ` |
| 62 | + + \";${Env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8.1 Tools\" ` |
| 63 | + + \";${Env:ProgramFiles(x86)}\Microsoft SDKs\ClickOnce\SignTool\") |
| 64 | + |
| 65 | +# Install Targeting Packs |
| 66 | +RUN powershell -Command "` |
| 67 | + $referenceAssembliesPath = \"${Env:ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\"; ` |
| 68 | + New-Item -ItemType Directory -Path ${referenceAssembliesPath}; ` |
| 69 | + foreach ($version in @('net40', 'net45', 'net451', 'net452', 'net46', 'net461', 'net462', 'net47', 'net471', 'net472', 'net48', 'net481')) { ` |
| 70 | + # Download reference assembly NuGet package ` |
| 71 | + $package = \"Microsoft.NETFramework.ReferenceAssemblies.${version}\"; ` |
| 72 | + nuget install \"${package}\" -DirectDownload -ExcludeVersion -Version 1.0.3 -OutputDirectory ${Env:TEMP}\Packages; ` |
| 73 | + $contents = \"${Env:TEMP}\Packages\${package}\build\.NETFramework\"; ` |
| 74 | + # Remove IntelliSense files ` |
| 75 | + Get-ChildItem -File -Recurse -Path \"${contents}\" | ` |
| 76 | + Where-Object { $_.FullName -match '^(?!.*(PermissionSets|RedistList)).*\.xml$' } | ` |
| 77 | + Remove-Item; ` |
| 78 | + Copy-Item -Recurse -Force -Container -Path ${contents} -Destination ${referenceAssembliesPath}; ` |
| 79 | + } ` |
| 80 | + Remove-Item -Force -Recurse ${Env:TEMP}\\*;" |
0 commit comments