microsoft / dotnet-framework-docker

The repo for the official docker images for .NET Framework on Windows Server Core.
https://hub.docker.com/_/microsoft-dotnet-framework
MIT License
698 stars 334 forks source link

WebBuildTools install not being committed to image? #152

Closed amitsaha closed 6 years ago

amitsaha commented 6 years ago

Hi all,

I am facing a very strange issue while attempting to add WebBuildTools to a dotnetframework:4.7.2-sdk image. My Dockerfile is as follows:

# escape=`
FROM microsoft/dotnet-framework:4.7.2-sdk

RUN Invoke-WebRequest -UseBasicParsing https://download.visualstudio.microsoft.com/download/pr/12210059/e64d79b40219aea618ce2fe10ebd5f0d/vs_BuildTools.exe -OutFile vs_BuildTools.exe; `
    # Installer won't detect DOTNET_SKIP_FIRST_TIME_EXPERIENCE if ENV is used, must use setx /M
    setx /M DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1; `
    Start-Process vs_BuildTools.exe -ArgumentList '--add', 'Microsoft.VisualStudio.Workload.WebBuildTools', '--quiet', '--norestart', '--nocache' -NoNewWindow -Wait; `
    Remove-Item -Force vs_buildtools.exe; `
    Remove-Item -Force -Recurse \"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\"; `
    Remove-Item -Force -Recurse ${Env:TEMP}\*; `
    Remove-Item -Force -Recurse \"${Env:ProgramData}\Package Cache\"
RUN Get-ChildItem -Directory \"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\"
CMD powershell

When I build it, the output of the Get-ChildItem is as follows:

$ docker build -t rsaus/dotnet-webbuildtools -f .\Dockerfile.dockerfile .

Directory: C:\Program Files (x86)\Microsoft Visual
    Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        5/23/2018  12:55 PM                Python Tools

Now, I manually start a container using the above built image and execute the above installation manually:

> docker run -ti rsaus/dotnet-webbuildtools powershell

PS C:\> Invoke-WebRequest -UseBasicParsing https://download.visualstudio.microsoft.com/download/pr/12210059/e64d79b40219aea618ce2fe10ebd5f0d/vs_BuildTools.exe -OutFile vs_BuildTools.exe
PS C:\> setx /M DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1

SUCCESS: Specified value was saved.

PS C:\> Start-Process vs_BuildTools.exe -ArgumentList '--add', 'Microsoft.VisualStudio.Workload.WebBuildTools', '--quiet', '--norestart', '--nocache' -NoNewWindow -Wait

PS C:\> Get-ChildItem -Directory \"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\"

 Directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        5/23/2018  12:55 PM                Python Tools
d-----        5/23/2018   1:00 PM                Web
d-----        5/23/2018   1:00 PM                WebApplications

And, I can see that the web build tools have been installed.

I have tried pretty much everything I can think of (introducing sleep after the install, for example), but I can't figure out what is going on here. Any ideas at all as to what I can try?

Thanks in advance.

MichaelSimons commented 6 years ago

@amitsaha, Do the latest sdk images eliminate your need for this? With #89, the web targets and tasks were added which should allow you to build aspnet projects.

MichaelSimons commented 6 years ago

FWIW, I did build the following Dockerfile and it appears to work as expected.

# escape=`
FROM microsoft/dotnet-framework:4.7.2-sdk

RUN Invoke-WebRequest -UseBasicParsing https://download.visualstudio.microsoft.com/download/pr/12210059/e64d79b40219aea618ce2fe10ebd5f0d/vs_BuildTools.exe -OutFile vs_BuildTools.exe; `
    Start-Process vs_BuildTools.exe -ArgumentList '--add', 'Microsoft.VisualStudio.Workload.WebBuildTools', '--quiet', '--norestart', '--nocache' -NoNewWindow -Wait; `
    Remove-Item -Force vs_buildtools.exe; `
    Remove-Item -Force -Recurse \"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\"; `
    Remove-Item -Force -Recurse ${Env:TEMP}\*;
RUN Get-ChildItem -Directory \"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\"
CMD powershell
Step 3/4 : RUN Get-ChildItem -Directory \"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\"
 ---> Running in d9a869f460eb

    Directory: C:\Program Files (x86)\Microsoft Visual
    Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        5/23/2018   2:42 PM                Python Tools
d-----        5/23/2018   2:46 PM                Web
d-----        5/23/2018   2:46 PM                WebApplications

When I built your Dockerfile it failed to build because \"${Env:ProgramData}\Package Cache\" didn't exist.

amitsaha commented 6 years ago

Do the latest sdk images eliminate your need for this? With #89, the web targets and tasks were added which should allow you to build aspnet projects.

@MichaelSimons thanks a lot - yes indeed it fixes my issue.

Still not sure what's happening with my Dockerfile or the one you pasted - it has the same earlier problem - but that's not required any more 👍