Docker - Windows Container - Install DotNet Framework 472

4

I am trying to setup a Windows Docker image with .net framework 4.7.2. For other reasons, I am starting from microsoft/windowsservercore

What I tried so far - I have choco installed on my image, so my initial solution was to use choco install

choco install dotnet4.7.2 --allow-empty-checksums -y -v --trace -d

What I get is 0x80004005

C:\users\ContainerAdministrator\AppData\Local\Temp\chocolatey> more .\dd_NDP472-KB4054530-x86-x64-AllOS-ENU_decompression_log.txt
??[5/25/2019, 22:26:33] === Logging started: 2019/05/25 22:26:33 ===
[5/25/2019, 22:26:33] Executable: C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\dotnetfx\4.7.2.20180712\NDP472-KB4054530-x86-x64-AllOS-ENU.exe v4.7.3081.0
[5/25/2019, 22:26:33] --- logging level: standard ---
[5/25/2019, 22:26:33] Successfully bound to the ClusApi.dll
[5/25/2019, 22:26:33] Error 0x800706d9: Failed to open the current cluster
[5/25/2019, 22:26:33] Cluster drive map: ''
[5/25/2019, 22:26:33] Considering drive: 'C:\'...
[5/25/2019, 22:26:33] Drive 'C:\' has been selected as the largest fixed drive
[5/25/2019, 22:26:33] Directory 'C:\b659e2a87b51ccf0f10d6292d1a4c2\' has been selected for file extraction
[5/25/2019, 22:26:33] Extracting files to: C:\b659e2a87b51ccf0f10d6292d1a4c2\
[5/25/2019, 22:26:33] Error 0x80004005: Failed to extract all files out of box container #0.
[5/25/2019, 22:26:33] Error 0x80004005: Failed to extract

https://blog.nowmicro.com/2015/02/23/deploying-net-framework-4-5-2-configmgr-application/

Following some the ideas from links above, I did :

  1. I downloaded manually NDP472-KB4054530-x86-x64-AllOS-ENU.exe
  2. I extracted it locally, on host, from command line (with /extract). Basically I have a local directory with all content of the NDP472 (including Setup.exe)
  3. I am running the container using volume

docker run --name cw10 -v C:\MyNDP472:C:\tmp -d client-windows10

  1. I am attaching to the container with cmd. From C:\tmp (which points to C:\MyNDP472 from host), I am running from command line.

Setup.exe /q /norestart /ChainingPackage "ADMINDEPLOYMENT" /x86 /x64 /redist /log "C:\tmp\reportdotnet.log"

  1. The result is Final Result: Installation completed successfully with success code: (0x80070BC2), "The requested operation is successful. Changes will not be effective until the system is rebooted.

enter image description here

  1. I am checking the registries (this time with Powershell)

Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |Get-ItemProperty -name Version,Release -EA 0 |Where { $_.PSChildName -match '^(?!S)\p{L}'} |Select PSChildName, Version, Release

  1. I still get previous version of .net framework (Full 4.6.01586 394802) - the one that comes with the base image. I reboot the container with docker restart. I get exactly the same. No changes.

My final goal : I want to build a C# sln solution with target 4.7.2.

I am out of ideas. Any thought?

Thanks

.net
powershell
docker
chocolatey
windows-container
asked on Stack Overflow May 26, 2019 by silverb77 • edited May 26, 2019 by silverb77

2 Answers

2
1

If you really want to do this without using an existing image, then you could create a powershell script to download and install it, and then call this from within your dockerfile:

Write-Host ".Net 4.7.2 not installed. Downloading..."
Invoke-WebRequest "http://go.microsoft.com/fwlink/?linkid=863265" -OutFile "NDP472-KB4054530-x86-x64-AllOS-ENU.exe"
Write-Host "Installing .Net 4.7.2..."
$exe = ".\NDP472-KB4054530-x86-x64-AllOS-ENU.exe"
&$exe /q /norestart

The DockerFile (assuming you name your script InstallNetFramework.ps1 and it lives in the same folder as your DockerFile:

FROM microsoft/windowsservercore 
RUN mkdir c:\install
ADD /InstallNetFramework.ps1 c:\install
RUN powershell c:\install\InstallNetFramework.ps1

But you are probably best using an image that already has .Net 4.7.2 installed because otherwise:

  • It's going to be slow every time you need to build your image (waiting for it to d/l and install .Net 4.7.2 every time)
  • You are going to need to update the download path should microsoft patch 4.7.2 in the future or move the download etc.

If you just do this once however, you could register this in your own personal Container Registry and use it as your base image for further DockerFiles (e.g. use this as the FROM)

answered on Stack Overflow Jul 31, 2019 by oatsoda

User contributions licensed under CC BY-SA 3.0