Reputation: 828
I want to create a docker image with a specific build environment, which involves having a VS2017 installed. I tried several approaches but overall I can't get VS2017 to install in a docker container. Reducing the dockerfile to the minimum, I try to run this:
FROM microsoft/windowsservercore
SHELL [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';" ]
RUN iwr -uri https://aka.ms/vs/15/release/vs_community.exe -outfile C:\vs_community.exe ; \
C:\vs_community.exe --allWorkloads --includeRecommended --includeOptional -q --passive --norestart --wait --all
And here is the log of the installation: https://gist.github.com/bazzilic/81fa3d8c4663540872be1d66cd1b0301
It looks like everything went fine, however, VS2017 is not installed in the end:
PS C:\> ls
Directory: C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/16/2016 9:18 PM PerfLogs
d-r--- 9/3/2017 7:45 PM Program Files
d----- 9/3/2017 7:41 PM Program Files (x86)
d-r--- 8/8/2017 5:27 AM Users
d----- 8/8/2017 5:25 AM Windows
-a---- 11/23/2016 6:45 AM 1894 License.txt
-a---- 9/3/2017 7:41 PM 1069968 vs_community.exe
PS C:\> cd '.\Program Files\'
PS C:\Program Files> ls
Directory: C:\Program Files
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/16/2016 9:18 PM Common Files
d----- 7/16/2016 9:18 PM internet explorer
d----- 9/3/2017 7:45 PM Windows Defender
d----- 7/16/2016 9:18 PM WindowsPowerShell
PS C:\Program Files> cd '..\Program Files (x86)\'
PS C:\Program Files (x86)> ls
Directory: C:\Program Files (x86)
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/16/2016 9:18 PM Common Files
d----- 7/16/2016 9:18 PM internet explorer
d----- 7/16/2016 9:18 PM Microsoft.NET
d----- 8/8/2017 5:16 AM Windows Defender
d----- 7/16/2016 9:18 PM WindowsPowerShell
PS C:\Program Files (x86)>
Any suggestions?
Upvotes: 3
Views: 3135
Reputation: 41
I am pasting a Dockerfile below which I used to successfully build a container with VS2017 community, git, Chocolatey, and NuGet installed. I did not install all the VS workloads, just 4, but it results in a large container.
You can run it with "docker container run -it -v C:/Temp:C:/DATA vs2017/community" to run it interactively and mount C:\Temp on your host as C:\data in your container (and presents you with the developer cmd prompt)
Hope this helps. Mark
# USAGE NOTES:
#
# Step 1)
# Docker => Settings => Daemon => Switch from Basic to Advanced
# Add :
# "storage-opts": [
# "size=120GB"
# ]
#
# Step 2)
# docker image build -t vs2017/community -m 2GB .
#
# References:
# https://learn.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio
# https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community
#
# NOTE: this build takes ~01:56:17.6201326 hrs on a surface book 2 15" with 16 GB RAM
# and results in an image size of 23.6GB
#
# Use the latest Windows Server Core image
FROM microsoft/windowsservercore:latest
# Download the tools
SHELL ["cmd", "/S", "/C"]
ADD "https://aka.ms/vs/15/release/vs_community.exe" "C:\TEMP\vs_community.exe"
ADD "https://dist.nuget.org/win-x86-commandline/v4.7.0/nuget.exe" "C:\TEMP\nuget.exe"
# Install VS 2017 community
RUN C:\TEMP\vs_community.exe --includeRecommended --includeOptional --quiet --nocache --norestart --wait \
--add Microsoft.VisualStudio.Workload.Azure \
--add Microsoft.VisualStudio.Workload.ManagedDesktop \
--add Microsoft.VisualStudio.Workload.NetCoreTools \
--add Microsoft.VisualStudio.Workload.NetWeb \
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
# Install SSDT NuGet
RUN "C:\TEMP\nuget.exe" install Microsoft.Data.Tools.Msbuild -Version 10.0.61804.210
# Install Chocolatey
ENV chocolateyUseWindowsCompression = false
SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
[System.Environment]::SetEnvironmentVariable('PATH', "\"${env:PATH};%ALLUSERSPROFILE%\chocolatey\bin\"", 'Machine'); \
choco feature enable -n allowGlobalConfirmation;
# Install git tools with chocolatey
RUN choco install git -y \
git-lfs -y \
git-credential-manager-for-windows -y
# Launch VS2017 developer command prompt when started
SHELL ["cmd", "/S", "/C"]
ENTRYPOINT [ "CMD", "/k", "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/Tools/VsDevCmd.bat" ]
Upvotes: 4