2

Can't seem to find any resource on how to have both .NET versions, 3.5 and 4.8 installed into a docker container.

I am currently using:

FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019

as my base image. But would also want .NET 3.5 for backwards compatibility. My attempts using their .NET 3.5 dockerfile to build but with the above base image have failed. This is for CICD purposes, creating a build environment.

1
  • What was failed? Commented Oct 7, 2020 at 7:56

1 Answer 1

3

The sdk:3.5-windowsservercore-ltsc2019 image does contain both 3.5 and 4.8. Have you tried that?

That will work for building the app, but if you want to run it in a runtime-related image that has both 3.5 and 4.8 for Windows Server 2019, there is no such official image that has both. If you specifically require the Windows Server 2019 image, you'll need to install 3.5 yourself. There's not an official image for 2019 that contains both 3.5 and 4.8. Other newer versions of Windows (1903+) have 4.8 installed by default, so in that case you could use their corresponding 3.5 images which would have both 3.5 and 4.8 installed.

Here's an example Dockerfile illustrating how you could install 3.5 onto a 4.8 runtime image for Windows Server 2019.

# escape=`
 
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
 
SHELL ["cmd", "/S", "/C"]
 
# Install .NET Fx 3.5
RUN curl -fSLo microsoft-windows-netfx3.zip https://dotnetbinaries.blob.core.windows.net/dockerassets/microsoft-windows-netfx3-1809.zip `
    && tar -zxf microsoft-windows-netfx3.zip `
    && del /F /Q microsoft-windows-netfx3.zip `
    && DISM /Online /Quiet /Add-Package /PackagePath:.\microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab `
    && del microsoft-windows-netfx3-ondemand-package~31bf3856ad364e35~amd64~~.cab `
    && powershell Remove-Item -Force -Recurse ${Env:TEMP}\*
 
# Apply latest patch
# This content will need to change each month as new security fixes are released for Windows. You can find the latest content that should be placed here by looking at the official Dockerfile: https://github.com/microsoft/dotnet-framework-docker/blob/master/src/runtime/3.5/windowsservercore-ltsc2019/Dockerfile#L13
 
# ngen .NET Fx
ENV COMPLUS_NGenProtectedProcess_FeatureEnabled 0
RUN \Windows\Microsoft.NET\Framework64\v2.0.50727\ngen uninstall "Microsoft.Tpm.Commands, Version=10.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=amd64" `
    && \Windows\Microsoft.NET\Framework64\v2.0.50727\ngen update `
    && \Windows\Microsoft.NET\Framework\v2.0.50727\ngen update
Sign up to request clarification or add additional context in comments.

1 Comment

sdk:3.5-windowsservercore-ltsc2019 has both .net frameworks, thanks

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.