windowsdockerchocolatey

Chocolatey installation in docker started to fail, restart due to .NET framework is suddenly needed


Chocolatey installation started to fail last week. Dockerfile starts with

FROM python:3.8.2-windowsservercore-ltsc2016
SHELL ["powershell","-Command"]
RUN "Set-ExecutionPolicy Bypass -Scope Process -Force; [Net.ServicePointManager]::SecurityProtocol = 'tls12'; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"

and log says:

Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org)
Getting latest version of the Chocolatey package for download.
Not using proxy.
Getting Chocolatey from https://community.chocolatey.org/api/v2/package/chocolatey/2.0.0.
Downloading https://community.chocolatey.org/api/v2/package/chocolatey/2.0.0 to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip
Not using proxy.
Extracting C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocoInstall
Installing Chocolatey on the local machine
The registry key for .Net 4.8 was not found or this is forced

Downloading 'https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/ndp48-x86-x64-allos-enu.exe' to 'C:\Users\ContainerAdministrator\AppData\Local\Temp\ndp48-x86-x64-allos-enu.exe' - the installer is 100+ MBs, so this could take a while on a slow connection.

Installing 'C:\Users\ContainerAdministrator\AppData\Local\Temp\ndp48-x86-x64-allos-enu.exe' - this may take awhile with no output.

.NET Framework 4.8 was installed, but a reboot is required. 

Please reboot the system and try to install/upgrade Chocolatey again.

How to solve this issue?


Solution

  • The requirement for .NET Framework 4.8 is something which has been talked about for a while, and something which is mentioned in both the release notes, and the upgrade guide.

    https://docs.chocolatey.org/en-us/choco/release-notes#may-31-2023

    Upgrade to target version 4.8 of the .NET Framework - see #2738.

    https://docs.chocolatey.org/en-us/guides/upgrading-to-chocolatey-v2-v6#net-framework-4.8-required

    We recommend you install .NET Framework 4.8 and reboot, before installing or upgrading to Chocolatey CLI v2.0.0. If you are installing Chocolatey in a Docker container, please use an image that already has .NET 4.8 installed or use the official Chocolatey CLI Docker image.

    You can see the base image that is used for the official Chocolatey Docker Image here:

    https://github.com/chocolatey/choco/blob/develop/docker/Dockerfile.windows#L1

    FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2016