3

As per title, I want to use dotnet core on dotnet framework aspnet image. A little bit of background, I have ASP.NET (4.6) application with dotnet core libraries. Currently it is running on IIS. Now, I'm looking forward to dockerize this by using windows server core image. No particular reason, just looking to dockerize and modernize legacy application.

  • I'm started with this image: mcr.microsoft.com/dotnet/framework/sdk

  • And I'm using this image as runtime: mcr.microsoft.com/dotnet/framework/aspnet

Problem is during runtime, the IIS inside aspnet doesn't recognize aspnetmodule. In IIS we normally install hosting bundle, how to do this on docker?

Thank you

2 Answers 2

1

Just for record keeping, am sharing this. What I did was I take the images from Microsoft and add installation for Hosting bundle. In this case, I'm using dotnet core 1.1:

# escape=`
ARG REPO=mcr.microsoft.com/dotnet/framework/runtime
FROM $REPO:4.8-windowsservercore-ltsc2019

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ADD dotnetcore.1.0.16_1.1.13-windowshosting.exe /install/
RUN Add-WindowsFeature Web-Server; `
    Add-WindowsFeature NET-Framework-45-ASPNET; `
    Add-WindowsFeature Web-Asp-Net45; `
    Remove-Item -Recurse C:\inetpub\wwwroot\*; `
    Invoke-WebRequest -Uri https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.6/ServiceMonitor.exe -OutFile C:\ServiceMonitor.exe

# Install Roslyn compilers and ngen binaries
RUN Invoke-WebRequest https://api.nuget.org/packages/microsoft.net.compilers.2.9.0.nupkg -OutFile c:\microsoft.net.compilers.2.9.0.zip; `
    Expand-Archive -Path c:\microsoft.net.compilers.2.9.0.zip -DestinationPath c:\RoslynCompilers; `
    Remove-Item c:\microsoft.net.compilers.2.9.0.zip -Force; `
    &C:\install\dotnetcore.1.0.16_1.1.13-windowshosting.exe /install /quiet | `
    &C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe install c:\RoslynCompilers\tools\csc.exe /ExeConfig:c:\RoslynCompilers\tools\csc.exe | `
    &C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe install c:\RoslynCompilers\tools\vbc.exe /ExeConfig:c:\RoslynCompilers\tools\vbc.exe | `
    &C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe install c:\RoslynCompilers\tools\VBCSCompiler.exe /ExeConfig:c:\RoslynCompilers\tools\VBCSCompiler.exe | `
    &C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe install c:\RoslynCompilers\tools\csc.exe /ExeConfig:c:\RoslynCompilers\tools\csc.exe | `
    &C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe install c:\RoslynCompilers\tools\vbc.exe /ExeConfig:c:\RoslynCompilers\tools\vbc.exe | `
    &C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe install c:\RoslynCompilers\tools\VBCSCompiler.exe  /ExeConfig:c:\RoslynCompilers\tools\VBCSCompiler.exe

ENV ROSLYN_COMPILER_LOCATION c:\\RoslynCompilers\\tools

EXPOSE 80

ENTRYPOINT ["C:\\ServiceMonitor.exe", "w3svc"]

I have no way to automate download for hosting bundle. You may need to download it from microsoft site: https://dotnet.microsoft.com/download/dotnet-core/2.2, choose runtime and hosting bundle.

Put it together with the Dockerfile so Docker can copy it into the image. This image can run on Windows Server 2019. For other version of Windows Server, you may need to use different tag.

P/S: Hosting bundle installation is a bit tricky, I used to extend the image but somehow the installation become ephemeral and lost. This is working for me, hope this helps.

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

Comments

0

Find download link of the .NET Core SDK you need here https://dotnet.microsoft.com/download/dotnet-core.

Here is sample for .NET Core 2.2

FROM mcr.microsoft.com/dotnet/framework/runtime:4.7.2 AS runtime

# Replace download URL with .NET Core SDK you need.
ADD https://download.visualstudio.microsoft.com/download/pr/7ae62589-2bc1-412d-a653-5336cff54194/b573c4b135280fb369e671a8f477163a/dotnet-sdk-2.2.100-win-x64.exe c:/setup

RUN C:/setup/dotnet-sdk-2.2.100-win-x64.exe /install /quiet

ENTRYPOINT ["dotnet", "YOUR_NET_CORE_DLL_NAME.dll"]

Comments

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.