Home:ALL Converter>How to use dotnet core on docker dotnet framework image

How to use dotnet core on docker dotnet framework image

Ask Time:2019-11-14T14:26:31         Author:Faizal Sidek

Json Formatter

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

Author:Faizal Sidek,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58850633/how-to-use-dotnet-core-on-docker-dotnet-framework-image
Faizal Sidek :

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:\n\n# escape=`\nARG REPO=mcr.microsoft.com/dotnet/framework/runtime\nFROM $REPO:4.8-windowsservercore-ltsc2019\n\nSHELL [\"powershell\", \"-Command\", \"$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';\"]\n\nADD dotnetcore.1.0.16_1.1.13-windowshosting.exe /install/\nRUN Add-WindowsFeature Web-Server; `\n Add-WindowsFeature NET-Framework-45-ASPNET; `\n Add-WindowsFeature Web-Asp-Net45; `\n Remove-Item -Recurse C:\\inetpub\\wwwroot\\*; `\n Invoke-WebRequest -Uri https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.6/ServiceMonitor.exe -OutFile C:\\ServiceMonitor.exe\n\n# Install Roslyn compilers and ngen binaries\nRUN Invoke-WebRequest https://api.nuget.org/packages/microsoft.net.compilers.2.9.0.nupkg -OutFile c:\\microsoft.net.compilers.2.9.0.zip; `\n Expand-Archive -Path c:\\microsoft.net.compilers.2.9.0.zip -DestinationPath c:\\RoslynCompilers; `\n Remove-Item c:\\microsoft.net.compilers.2.9.0.zip -Force; `\n &C:\\install\\dotnetcore.1.0.16_1.1.13-windowshosting.exe /install /quiet | `\n &C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\ngen.exe install c:\\RoslynCompilers\\tools\\csc.exe /ExeConfig:c:\\RoslynCompilers\\tools\\csc.exe | `\n &C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\ngen.exe install c:\\RoslynCompilers\\tools\\vbc.exe /ExeConfig:c:\\RoslynCompilers\\tools\\vbc.exe | `\n &C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\ngen.exe install c:\\RoslynCompilers\\tools\\VBCSCompiler.exe /ExeConfig:c:\\RoslynCompilers\\tools\\VBCSCompiler.exe | `\n &C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\ngen.exe install c:\\RoslynCompilers\\tools\\csc.exe /ExeConfig:c:\\RoslynCompilers\\tools\\csc.exe | `\n &C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\ngen.exe install c:\\RoslynCompilers\\tools\\vbc.exe /ExeConfig:c:\\RoslynCompilers\\tools\\vbc.exe | `\n &C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\ngen.exe install c:\\RoslynCompilers\\tools\\VBCSCompiler.exe /ExeConfig:c:\\RoslynCompilers\\tools\\VBCSCompiler.exe\n\nENV ROSLYN_COMPILER_LOCATION c:\\\\RoslynCompilers\\\\tools\n\nEXPOSE 80\n\nENTRYPOINT [\"C:\\\\ServiceMonitor.exe\", \"w3svc\"]\n\n\nI 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.\n\nPut 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.\n\n\n P/S: Hosting bundle installation is a bit tricky, I used to extend the\n image but somehow the installation become ephemeral and lost. This is\n working for me, hope this helps.\n",
2019-11-14T06:26:31
yy