14

I am struggling to install .NET Framework 3.5 on docker container. I have 4.5 installed already, but need 3.5 to run one Service. Here is my Dockerfile:

FROM microsoft/windowsservercore
SHELL ["powershell"]


RUN Install-WindowsFeature NET-Framework-45-ASPNET ; \  
    Install-WindowsFeature Web-Asp-Net45

RUN dism /online /enable-feature /featurename:NetFX3 /all

COPY Startup Startup
COPY Service Service



RUN "C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" WCS.WindowsService.exe


RUN mkdir Temp\Logs

ENTRYPOINT C:\Startup\setupBatch.bat

COPY ContainerApi ContainerApi

RUN Remove-WebSite -Name 'Default Web Site'  
RUN New-Website -Name 'ContainerApi' -Port 80 \  
    -PhysicalPath 'C:\ContainerApi' -ApplicationPool '.NET v4.5'

EXPOSE 80

CMD ["ping", "-t", "localhost"]  

When I try to build this, it gives me error on line RUN dism

Error: 0x800f081f

The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.

Now, even if I run dism /online /enable-feature /featurename:NetFX3 /all inside the docker (docker exec) it will still give me the same error.

Anyone with any help?

2 Answers 2

18

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/

Sign up to request clarification or add additional context in comments.

5 Comments

I know I have to avoid the +1 or thanks comments, but you sir are a life savior
No luck following these exact instructions it will still fail. This is probably not the correct solution.
@After_Sunset I just did this - it works. The only caveat is that one has to enable the Windows Update service on the docker instance, since it'll likely be disabled by default and Install-WindowsFeature requires this to work even when providing sources. You can disable the service afterwards.
@MBender could you please share the steps you followed to enable the Windows Update service on the docker instance
In my own Dockerfile for an image incorporating .NET 3.5 I'm using the following (this is all one multi-line RUN command, but I can't \r\n in SOs comments): RUN powershell Set-Service -Name wuauserv -StartupType Manual; ` Install-WindowsFeature -Name NET-Framework-Features -Verbose; ` Set-Service -Name wuauserv -StartupType Disabled; ` Stop-Service -Name wuauserv -NoWait
13

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.

4 Comments

This base image is working well for me. I would rather not have to obtain an ISO image and run an additional command during the image build process, so this is a perfect solution for my needs.
WARNING: This base image does not have security patches applied, and therefore (beyond being out-of-date security-wise) will not work on hosts that have the February 2020 security patches per: support.microsoft.com/en-us/help/4542617/…
Sadly, this is the only solution, I've tried tons of things, and eventually, I used the image mentioned in the answer to use dotnet 3.5. In my case, I'm using WiX Toolset to build the installer of the app, so having a separate Docker (Windows) image for that is okayish.
Same situation as you @MeirGabay. Wix is after dotnet 3.5 but this code is 4.8. Don't think a 3.5 container is going to help me in that case :/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.