Search code examples
c#dockermsbuildwindows-server

C# Unhandled Exception (with no message) using Docker windowsservercore


microsoft.com/dotnet/framework/runtime:4.6.2-windowsservercore-ltsc2016image to run a.Net Framework 4.6.1project that was built withMSbuild`, it runs fine running it stand alone in a windows machine but when it comes to docker it doesn't work and the only exception I got is an empty message

PS C:\app> .\MyProject.Rest.exe

Unhandled Exception:

I have the following version of .Net Framework installed on the container

PS C:\app> (Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Version
4.8.03761
PS C:\app> Get-ComputerInfo | select WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer

WindowsProductName             WindowsVersion OsHardwareAbstractionLayer
------------------             -------------- --------------------------
Windows Server 2016 Datacenter                10.0.14393.3297


PS C:\app>

The Dockerfile contains the following:

FROM mcr.microsoft.com/dotnet/framework/runtime:4.6.2-windowsservercore-ltsc2016
SHELL ["powershell"]

COPY . 'C:\\app\\'
EXPOSE 10003
WORKDIR 'C:\\app\\'

CMD MyProject.Rest.exe

And the project was build with the following command:

MSBuild.exe '.\Project\Project.sln' /t:Build /p:Configuration=Release /p:Platform="Any CPU" /p:RunOctoPack=true /p:OctoPackPackageVersion=$env:appveyor_build_version

Any help will be appreciated.


Solution

  • The problem was the run environment, we use Windows Server 2012 and some features are not supported after the update to Windows Server 2016 everything works fine.