Found a longstanding docker launch configuration issue with an application when deploying to AWS ECS

This was the configuration which compiles and runs locally without issue.  However every time it was deployed to ECS it would compile->build->deploy.  When it came to the deploy step it would fault crash and trigger AWS health check on the container which would then not deploy and leave the ECS group at its minimum size (this was occurring in Development so the effect was frustration not catastrophe)

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>    
    <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>AppName</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>AppName</PackageId>
  </PropertyGroup>

What is the root problem thought?  The ECS docker container was grabbing the nuget references and dependencies (this is normal behavior), but almost all the dependencies AWS SDK, CsvHelper, Mailkit, etc had moved their compatibility to the latest patch of  .NET Core Framework at this time 2.1.6.  This means that when the docker container is building the image it grabs the 2.1.6 libraries as they are sematically versioned as 2.1 compatible and then under a Linux container which this docker image is running (ubuntu) it will crash on launch.

The solution is to float the target framework so that the Major.Minor compatible version will work with the latest patched version like so

<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

Giving you this project configuration and then the docker container will again pull down the latest compatible patched framework dependencies and launch

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
    <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>AppName</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>AppName</PackageId>
  </PropertyGroup>