Developer Package missing in .NET SDK5 docker image

Viewed 578

I am trying to publish a c# project via docker image mcr.microsoft.com/dotnet/sdk:5.0 (https://hub.docker.com/_/microsoft-dotnet-sdk/).

In one of the *.csproj files is a definition like <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>

I am getting the following error

/usr/share/dotnet/sdk/5.0.301/Microsoft.Common.CurrentVersion.targets(1216,5): error MSB3644: 
The reference assemblies for .NETFramework,Version=v4.6.1 were not found. 
To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. 
You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

I have tried to install some dependencies from https://hub.docker.com/_/microsoft-dotnet-runtime-deps/ but this doesnt help me out.

I have searched hours to find a tutorial to install Developer Packs in linux distributions but found nothing.

Any ideas?

1 Answers

I think you are confusing Net Core with Net Framework.

To use Net Core: In .csproj file Change <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> to <TargetFrameworkVersion>net5.0</TargetFrameworkVersion> and fix the dependencies to work with Net Core

To use Net Framework: Change the docker image to mcr.microsoft.com/dotnet/framework/sdk:4.6

Related