Skip to content

Commit bfc9dbd

Browse files
authored
Fix vs2017 / vs2019 containers (#11)
1 parent 7935c0d commit bfc9dbd

File tree

4 files changed

+181
-40
lines changed

4 files changed

+181
-40
lines changed
File renamed without changes.
File renamed without changes.

windows/vs2017-server2019/Dockerfile

+81-40
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
FROM microsoft/dotnet-framework:4.7.2-sdk-windowsservercore-ltsc2019
1+
# Because its impossible to search for microsoft images anymore:
2+
# https://hub.docker.com/_/microsoft-dotnet-framework-sdk
3+
# NOTE: DO NOT use "mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019" as it uses vs2019
4+
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
5+
6+
# https://github.com/microsoft/dotnet-framework-docker/blob/7ea28f0c8e9ca278eb5d38c67fe67987e8432ed8/4.8/sdk/windowsservercore-1903/Dockerfile
27
# See https://github.com/Microsoft/dotnet-framework-docker/blob/33531c3bae718f970b704730703ba1fb0f3dff80/4.7.2/sdk/windowsservercore-ltsc2019/Dockerfile
38

49
# Container Compatibility
510
# See https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility
611

7-
# We use the same configuration as Microsoft's VSTS agents
8-
# https://github.com/Microsoft/vsts-agent-docker/blob/master/windows/servercore/10.0.14393/standard/VS2017/Dockerfile
12+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
913

1014
ENV chocolateyUseWindowsCompression=false
11-
1215
RUN iex (wget 'https://chocolatey.org/install.ps1' -UseBasicParsing)
1316

17+
RUN choco feature enable -n=allowGlobalConfirmation
1418
RUN choco feature disable -n=showDownloadProgress
1519
RUN choco config set cachelocation C:\chococache
1620

@@ -21,24 +25,23 @@ RUN choco install \
2125
curl \
2226
maven \
2327
gradle \
24-
docker \
25-
--confirm \
28+
docker-cli \
2629
--limit-output \
2730
--timeout 3600 \
2831
; Remove-Item C:\chococache -Recurse -Force
2932

33+
# Package parameters is BROKEN
34+
# --package-parameters '--passive --includeOptional --locale en-US' \
35+
3036
RUN choco install \
3137
visualstudio2017enterprise \
32-
--package-parameters "--passive --locale en-US --includeOptional" \
33-
--confirm \
3438
--limit-output \
3539
--timeout 3600 \
3640
; Remove-Item C:\chococache -Recurse -Force
3741

3842
RUN choco install \
3943
visualstudio2017-workload-netcoretools \
4044
visualstudio2017-workload-netweb \
41-
--confirm \
4245
--limit-output \
4346
--timeout 3600 \
4447
--ignore-package-exit-codes \
@@ -51,53 +54,91 @@ RUN choco install \
5154
netfx-4.7.2-devpack \
5255
netfx-4.6.2-devpack \
5356
netfx-4.5.2-devpack \
54-
netfx-4.0.3-devpack \
55-
--confirm \
5657
--limit-output \
5758
--timeout 1800 \
5859
--ignore-package-exit-codes \
5960
; Remove-Item C:\chococache -Recurse -Force
6061

61-
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
62-
63-
# Install .NET Core 1.0.5, 1.1.2
64-
ENV DOTNET_DOWNLOAD_URL https://download.microsoft.com/download/D/7/A/D7A9E4E9-5D25-4F0C-B071-210CB8267943/dotnet-win-x64.1.1.2.zip
65-
ENV DOTNET_SDK_DOWNLOAD_URL https://download.microsoft.com/download/E/7/8/E782433E-7737-4E6C-BFBF-290A0A81C3D7/dotnet-dev-win-x64.1.0.4.zip
62+
# Download the Build Tools bootstrapper.
63+
ADD "https://aka.ms/vs/15/release/vs_buildtools.exe" "C:\TEMP\vs_buildtools.exe"
64+
65+
SHELL ["cmd", "/S", "/C"]
66+
67+
# Installer won't detect DOTNET_SKIP_FIRST_TIME_EXPERIENCE if ENV is used, must use setx /M
68+
# Install VS components
69+
RUN setx /M DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1 \
70+
&& start /w C:\TEMP\vs_BuildTools.exe ^ \
71+
--add Microsoft.VisualStudio.Workload.MSBuildTools ^ \
72+
--add Microsoft.VisualStudio.Workload.NetCoreBuildTools ^ \
73+
--add Microsoft.Component.ClickOnce.MSBuild ^ \
74+
--add Microsoft.VisualStudio.Component.WebDeploy ^ \
75+
--quiet --norestart --nocache --wait \
76+
&& powershell -Command "if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { throw $err }" \
77+
&& del C:\TEMP\vs_BuildTools.exe \
78+
\
79+
# Cleanup
80+
&& rmdir /S /Q "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer" \
81+
&& powershell Remove-Item -Force -Recurse "%TEMP%\*" \
82+
&& rmdir /S /Q "%ProgramData%\Package Cache"
83+
84+
# Install web targets
85+
RUN curl -fSLo MSBuild.Microsoft.VisualStudio.Web.targets.zip https://dotnetbinaries.blob.core.windows.net/dockerassets/MSBuild.Microsoft.VisualStudio.Web.targets.2020.03.zip \
86+
&& tar -zxf MSBuild.Microsoft.VisualStudio.Web.targets.zip -C "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0" \
87+
&& del MSBuild.Microsoft.VisualStudio.Web.targets.zip
88+
89+
# Set PATH in one layer to keep image size down.
90+
RUN powershell setx /M PATH $(${Env:PATH} \
91+
+ \";${Env:ProgramFiles}\NuGet\" \
92+
+ \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\" \
93+
+ \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\" \
94+
+ \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\" \
95+
+ \";${Env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\" \
96+
+ \";${Env:ProgramFiles(x86)}\Microsoft SDKs\ClickOnce\SignTool\")
6697

67-
RUN Invoke-WebRequest $Env:DOTNET_DOWNLOAD_URL -OutFile dotnet.zip; \
68-
Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
69-
Remove-Item -Force dotnet.zip
70-
71-
RUN Invoke-WebRequest $Env:DOTNET_SDK_DOWNLOAD_URL -OutFile dotnet.zip; \
72-
Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
73-
Remove-Item -Force dotnet.zip
74-
75-
# Install .NET Core 2.0
76-
ENV DOTNET_DOWNLOAD_URL https://download.microsoft.com/download/5/F/0/5F0362BD-7D0A-4A9D-9BF9-022C6B15B04D/dotnet-runtime-2.0.0-win-x64.zip
77-
ENV DOTNET_SDK_DOWNLOAD_URL https://download.microsoft.com/download/1/B/4/1B4DE605-8378-47A5-B01B-2C79D6C55519/dotnet-sdk-2.0.0-win-x64.zip
98+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
7899

79-
RUN Invoke-WebRequest $Env:DOTNET_DOWNLOAD_URL -OutFile dotnet.zip; \
80-
Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
100+
# Targeting Packs
101+
RUN "@('4.0', '4.5.2', '4.6.2', '4.7.2', '4.8') | %{ \
102+
Invoke-WebRequest \
103+
-UseBasicParsing \
104+
-Uri https://dotnetbinaries.blob.core.windows.net/referenceassemblies/v${_}.zip \
105+
-OutFile referenceassemblies.zip; \
106+
Expand-Archive referenceassemblies.zip \
107+
-DestinationPath \"${Env:ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\.NETFramework\" \
108+
-Force; \
109+
Remove-Item -Force referenceassemblies.zip; \
110+
}"
111+
112+
# Install .NET Core 2.1
113+
RUN Invoke-WebRequest \
114+
"https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.806/dotnet-sdk-2.1.806-win-x64.zip" \
115+
-OutFile dotnet.zip; \
116+
Expand-Archive dotnet.zip \
117+
-DestinationPath "${Env:ProgramFiles}\dotnet" \
118+
-Force; \
81119
Remove-Item -Force dotnet.zip
82120

83-
RUN Invoke-WebRequest $Env:DOTNET_SDK_DOWNLOAD_URL -OutFile dotnet.zip; \
84-
Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
121+
# Install .NET Core 3.1
122+
RUN Invoke-WebRequest \
123+
"https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.202/dotnet-sdk-3.1.202-win-x64.zip" \
124+
-OutFile dotnet.zip; \
125+
Expand-Archive dotnet.zip \
126+
-DestinationPath "${Env:ProgramFiles}\dotnet" \
127+
-Force; \
85128
Remove-Item -Force dotnet.zip
86129

87-
# Install .NET Core 2.2
88-
ENV DOTNET_DOWNLOAD_URL https://download.visualstudio.microsoft.com/download/pr/c332d70f-6582-4471-96af-4b0c17a616ad/5f3043d4bc506bf91cb89fa90462bb58/dotnet-sdk-2.2.103-win-x64.zip
130+
SHELL ["cmd", "/S", "/C"]
89131

90-
RUN Invoke-WebRequest $Env:DOTNET_DOWNLOAD_URL -OutFile dotnet.zip; \
91-
Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
92-
Remove-Item -Force dotnet.zip
132+
# In order to set system PATH, ContainerAdministrator must be used
133+
USER ContainerAdministrator
134+
RUN setx /M PATH "%PATH%;C:\Program Files\dotnet"
135+
USER ContainerUser
93136

94-
RUN [Environment]::SetEnvironmentVariable('PATH', "${Env:path}" + ';C:\Program Files (x86)\MSBuild\15.0\Bin', [EnvironmentVariableTarget]::Machine);
95-
RUN [Environment]::SetEnvironmentVariable('PATH', "${Env:path}" + ';C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE', [EnvironmentVariableTarget]::Machine);
96-
RUN [Environment]::SetEnvironmentVariable('PATH', "${Env:path}" + ';C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow', [EnvironmentVariableTarget]::Machine);
97-
RUN [Environment]::SetEnvironmentVariable('PATH', "${Env:path}" + ';C:\Program Files\dotnet', [EnvironmentVariableTarget]::Machine);
137+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
98138

99139
# Trigger the population of the local package cache
100140
ENV NUGET_XMLDOC_MODE skip
141+
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
101142

102143
RUN dotnet --list-sdks ; \
103144
mkdir C:\warmup ; \

windows/vs2019-server2019/Dockerfile

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Because its impossible to search for microsoft images anymore:
2+
# https://hub.docker.com/_/microsoft-dotnet-framework-sdk
3+
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019
4+
5+
# https://github.com/microsoft/dotnet-framework-docker/blob/7ea28f0c8e/4.8/sdk/windowsservercore-ltsc2019/Dockerfile
6+
7+
# Container Compatibility
8+
# See https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility
9+
10+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
11+
12+
ENV chocolateyUseWindowsCompression=false
13+
RUN iex (wget 'https://chocolatey.org/install.ps1' -UseBasicParsing)
14+
15+
RUN choco feature enable -n=allowGlobalConfirmation
16+
RUN choco feature disable -n=showDownloadProgress
17+
RUN choco config set cachelocation "/chococache"
18+
19+
RUN choco install \
20+
git \
21+
nodejs \
22+
jdk8 \
23+
curl \
24+
maven \
25+
gradle \
26+
docker-cli \
27+
--limit-output \
28+
--timeout 3600 \
29+
; Remove-Item "/chococache" -Recurse -Force
30+
31+
# Package parameters is BROKEN
32+
# --package-parameters '--passive --includeOptional --locale en-US' \
33+
RUN choco install \
34+
visualstudio2019enterprise \
35+
--limit-output \
36+
--timeout 3600 \
37+
; Remove-Item "/chococache" -Recurse -Force
38+
39+
# Already installed in base image:
40+
# - NuGet
41+
# - visualstudio2019-workload-netcoretools
42+
# - Microsoft.Net.Component.4.8.SDK
43+
# - Microsoft.VisualStudio.Workload.MSBuildTools
44+
RUN choco install \
45+
visualstudio2019-workload-netweb \
46+
visualstudio2019-workload-webbuildtools \
47+
--limit-output \
48+
--timeout 3600 \
49+
--ignore-package-exit-codes \
50+
--package-parameters "--includeOptional" \
51+
; Remove-Item "/chococache" -Recurse -Force
52+
53+
# Install .NET Framework 4.5, 4.6, 4.7, 4.8
54+
RUN choco install \
55+
netfx-4.8-devpack \
56+
netfx-4.7.2-devpack \
57+
netfx-4.6.2-devpack \
58+
netfx-4.5.2-devpack \
59+
--limit-output \
60+
--timeout 1800 \
61+
--ignore-package-exit-codes \
62+
; Remove-Item "/chococache" -Recurse -Force
63+
64+
# Install .NET Core 2.1
65+
RUN Invoke-WebRequest \
66+
"https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.806/dotnet-sdk-2.1.806-win-x64.zip" \
67+
-OutFile dotnet.zip; \
68+
Expand-Archive dotnet.zip \
69+
-DestinationPath "${Env:ProgramFiles}\dotnet" \
70+
-Force; \
71+
Remove-Item -Force dotnet.zip
72+
73+
# Install .NET Core 3.1
74+
RUN Invoke-WebRequest \
75+
"https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.202/dotnet-sdk-3.1.202-win-x64.zip" \
76+
-OutFile dotnet.zip; \
77+
Expand-Archive dotnet.zip \
78+
-DestinationPath "${Env:ProgramFiles}\dotnet" \
79+
-Force; \
80+
Remove-Item -Force dotnet.zip
81+
82+
SHELL ["cmd", "/S", "/C"]
83+
84+
# In order to set system PATH, ContainerAdministrator must be used
85+
USER ContainerAdministrator
86+
RUN setx /M PATH "%PATH%;C:\Program Files\dotnet"
87+
USER ContainerUser
88+
89+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
90+
91+
# Trigger the population of the local package cache
92+
ENV NUGET_XMLDOC_MODE skip
93+
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
94+
95+
RUN dotnet --list-sdks ; \
96+
mkdir C:\warmup ; \
97+
cd C:\warmup ; \
98+
dotnet new ; \
99+
cd .. ; \
100+
Remove-Item C:\warmup -Force -Recurse

0 commit comments

Comments
 (0)