Install .NET Framework 3.5 on Windows Server Core Docker

I took the following steps to resolve this issue:

  1. Got hold of the Windows Server 2016 Core ISO file. Mounted the file on local computer.
  2. Extracted the {mount}:/sources/sxs folder into a zip file (sxs.zip). Ensure that the .NET Framework 3.5 cab file (microsoft-windows-netfx3-ondemand-package.cab) is present in the sxs folder. In my case, this was the only file present in the sxs folder.

sxs folder

  1. Copy the sxs.zip file to my container. I copied it using the dockerfile of the image.
  2. Unzip the file to C:\sources\sxs folder in the container.
  3. Used the Install-WindowsFeature powershell command to install the feature.

    Install-WindowsFeature -Name NET-Framework-Features -Source C:\sources\sxs -Verbose
    

    install command

Hope this helps. I also found the following blog useful in understanding the on-demand features. https://blogs.technet.microsoft.com/askcore/2012/05/14/windows-8-and-net-framework-3-5/


For those who are still are in need of .Net3.5 and .Net4.X (4.7.2 for my case) version in one image.

Please note that MSFT is aware of this demand, and have a base image for this scenario.

Use FROM mcr.microsoft.com/dotnet/framework/sdk:3.5-20191008-windowsservercore-ltsc2019 in your dockerfile.

Saved me all the installation hassles.