/
Dockerfile
78 lines (70 loc) · 4.4 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
# escape=`
ARG REPO=mcr.microsoft.com/dotnet/framework/runtime
FROM $REPO:4.8-windowsservercore-ltsc2019
# Install NuGet CLI
ENV NUGET_VERSION=5.8.1
RUN mkdir "%ProgramFiles%\NuGet\latest" `
&& curl -fSLo "%ProgramFiles%\NuGet\nuget.exe" https://dist.nuget.org/win-x86-commandline/v%NUGET_VERSION%/nuget.exe `
&& mklink "%ProgramFiles%\NuGet\latest\nuget.exe" "%ProgramFiles%\NuGet\nuget.exe"
# Install VS components
RUN `
# Install VS Test Agent
curl -fSLo vs_TestAgent.exe https://download.visualstudio.microsoft.com/download/pr/5c555b0d-fffd-45a2-9929-4a5bb59479a4/521a04a4647eefe3e1364cfdcbbc5143f829cfcbd40e325afd330916daa3c075/vs_TestAgent.exe `
&& start /w vs_TestAgent --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_TestAgent.exe `
`
# Install VS Build Tools
&& curl -fSLo vs_BuildTools.exe https://download.visualstudio.microsoft.com/download/pr/5c555b0d-fffd-45a2-9929-4a5bb59479a4/45fd615bc29fadc5201483dad883e635c0ceecb0bddf0f613edf6093cb431a27/vs_BuildTools.exe `
&& start /w vs_BuildTools ^ `
--add Microsoft.VisualStudio.Workload.MSBuildTools ^ `
--add Microsoft.VisualStudio.Workload.NetCoreBuildTools ^ `
--add Microsoft.Net.Component.4.8.SDK ^ `
--add Microsoft.Component.ClickOnce.MSBuild ^ `
--add Microsoft.VisualStudio.Component.WebDeploy ^ `
--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"
# Install web targets
RUN curl -fSLo MSBuild.Microsoft.VisualStudio.Web.targets.zip https://dotnetbinaries.blob.core.windows.net/dockerassets/MSBuild.Microsoft.VisualStudio.Web.targets.2021.03.zip `
&& tar -zxf MSBuild.Microsoft.VisualStudio.Web.targets.zip -C "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VisualStudio\v16.0" `
&& del MSBuild.Microsoft.VisualStudio.Web.targets.zip
ENV ROSLYN_COMPILER_LOCATION="C:\Program Files (x86)\Microsoft Visual Studio\2019\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\2019\TestAgent\Common7\IDE\CommonExtensions\Microsoft\TestWindow\" `
+ \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\" `
+ \";${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 " `
$ErrorActionPreference = 'Stop'; `
$ProgressPreference = 'SilentlyContinue'; `
@('4.0', '4.5.2', '4.6.2', '4.7.2', '4.8') `
| %{ `
Invoke-WebRequest `
-UseBasicParsing `
-Uri https://dotnetbinaries.blob.core.windows.net/referenceassemblies/v${_}.zip `
-OutFile referenceassemblies.zip; `
Expand-Archive referenceassemblies.zip -DestinationPath \"${Env:ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\.NETFramework\"; `
Remove-Item -Force referenceassemblies.zip; `
}"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]