-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy pathDockerfile
134 lines (125 loc) · 7.08 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# escape=`
ARG REPO=mcr.microsoft.com/dotnet/framework/runtime
FROM $REPO:3.5-20250408-windowsservercore-ltsc2016
RUN `
# Install .NET 4.8 Fx
powershell -Command `
$ProgressPreference = 'SilentlyContinue'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest `
-UseBasicParsing `
-Uri https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/ndp48-x86-x64-allos-enu.exe `
-OutFile dotnet-framework-installer.exe `
&& .\dotnet-framework-installer.exe /q `
&& del .\dotnet-framework-installer.exe `
&& powershell Remove-Item -Force -Recurse ${Env:TEMP}\* `
`
# Apply latest patch
&& powershell -Command `
$ProgressPreference = 'SilentlyContinue'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest `
-UseBasicParsing `
-Uri https://catalog.s.download.windowsupdate.com/d/msdownload/update/software/updt/2025/03/windows10.0-kb5055170-x64-ndp48_72a6e45b3bb4da01a3bcf0379e263ef2bb23b034.msu `
-OutFile patch.msu; `
&& mkdir patch `
&& expand patch.msu patch -F:* `
&& del patch.msu `
&& dism /Online /Quiet /Add-Package /PackagePath:C:\patch\windows10.0-KB5055170-x64-ndp48.cab `
&& rmdir /S /Q patch `
`
# ngen .NET Fx
&& %windir%\Microsoft.NET\Framework64\v2.0.50727\ngen uninstall "Microsoft.Tpm.Commands, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" `
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen update `
&& %windir%\Microsoft.NET\Framework\v4.0.30319\ngen update
# Install NuGet CLI
ENV NUGET_VERSION=6.13.2
RUN mkdir "%ProgramFiles%\NuGet\latest" `
&& powershell -Command `
$ProgressPreference = 'SilentlyContinue'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest `
-UseBasicParsing `
-Uri https://dist.nuget.org/win-x86-commandline/v$Env:NUGET_VERSION/nuget.exe `
-OutFile $Env:ProgramFiles\NuGet\nuget.exe; `
&& mklink "%ProgramFiles%\NuGet\latest\nuget.exe" "%ProgramFiles%\NuGet\nuget.exe"
# Do not generate certificate
ENV DOTNET_GENERATE_ASPNET_CERTIFICATE=false
# Install VS components
RUN `
# Install VS Test Agent
powershell -Command `
$ProgressPreference = 'SilentlyContinue'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest `
-UseBasicParsing `
-Uri https://aka.ms/vs/17/release/vs_TestAgent.exe `
-OutFile vs_TestAgent.exe `
&& start /w vs_TestAgent --quiet --norestart --nocache --wait --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\TestAgent" `
&& powershell -Command "if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { throw $err }" `
&& del vs_TestAgent.exe `
`
# Install VS Build Tools
&& powershell -Command `
$ProgressPreference = 'SilentlyContinue'; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
Invoke-WebRequest `
-UseBasicParsing `
-Uri https://aka.ms/vs/17/release/vs_BuildTools.exe `
-OutFile vs_BuildTools.exe `
&& start /w vs_BuildTools ^ `
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" ^ `
--add Microsoft.Component.ClickOnce.MSBuild ^ `
--add Microsoft.Net.Component.4.8.SDK ^ `
--add Microsoft.NetCore.Component.Runtime.8.0 ^ `
--add Microsoft.NetCore.Component.Runtime.9.0 ^ `
--add Microsoft.NetCore.Component.SDK ^ `
--add Microsoft.VisualStudio.Component.NuGet.BuildTools ^ `
--add Microsoft.VisualStudio.Component.WebDeploy ^ `
--add Microsoft.VisualStudio.Web.BuildTools.ComponentGroup ^ `
--add Microsoft.VisualStudio.Workload.MSBuildTools ^ `
--quiet --norestart --nocache --wait `
&& powershell -Command "if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { throw $err }" `
&& del vs_BuildTools.exe `
`
# Trigger dotnet first run experience by running arbitrary cmd
&& "%ProgramFiles%\dotnet\dotnet" help `
`
# Workaround for issues with 64-bit ngen
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen uninstall "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\SecAnnotate.exe" `
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen uninstall "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\WinMDExp.exe" `
`
# ngen assemblies queued by VS installers
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen update `
&& %windir%\Microsoft.NET\Framework\v4.0.30319\ngen update `
`
# Cleanup
&& (for /D %i in ("%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\*") do rmdir /S /Q "%i") `
&& (for %i in ("%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\*") do if not "%~nxi" == "vswhere.exe" del "%~i") `
&& powershell Remove-Item -Force -Recurse "%TEMP%\*" `
&& rmdir /S /Q "%ProgramData%\Package Cache"
ENV ROSLYN_COMPILER_LOCATION="C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\Roslyn"
# Set PATH in one layer to keep image size down.
RUN powershell setx /M PATH $(${Env:PATH} `
+ \";${Env:ProgramFiles}\NuGet\" `
+ \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\TestAgent\Common7\IDE\CommonExtensions\Microsoft\TestWindow\" `
+ \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\" `
+ \";${Env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\" `
+ \";${Env:ProgramFiles(x86)}\Microsoft SDKs\ClickOnce\SignTool\")
# Install Targeting Packs
RUN powershell -Command "`
$referenceAssembliesPath = \"${Env:ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\"; `
New-Item -ItemType Directory -Path ${referenceAssembliesPath}; `
foreach ($version in @('net40', 'net45', 'net451', 'net452', 'net46', 'net461', 'net462', 'net47', 'net471', 'net472', 'net48', 'net481')) { `
# Download reference assembly NuGet package `
$package = \"Microsoft.NETFramework.ReferenceAssemblies.${version}\"; `
nuget install \"${package}\" -DirectDownload -ExcludeVersion -Version 1.0.3 -OutputDirectory ${Env:TEMP}\Packages; `
$contents = \"${Env:TEMP}\Packages\${package}\build\.NETFramework\"; `
# Remove IntelliSense files `
Get-ChildItem -File -Recurse -Path \"${contents}\" | `
Where-Object { $_.FullName -match '^(?!.*(PermissionSets|RedistList)).*\.xml$' } | `
Remove-Item; `
Copy-Item -Recurse -Force -Container -Path ${contents} -Destination ${referenceAssembliesPath}; `
} `
Remove-Item -Force -Recurse ${Env:TEMP}\\*;"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]