0

I have the following dockerfile, the project works fine when running through Visual Studio:

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env

WORKDIR /app

# Copy everything
COPY . ./

RUN dotnet build Inventory.sln -c Release -o /out

The problem is when I build it. The build phase gives me this error:

C:\Program Files\dotnet\sdk\5.0.407\Microsoft.Common.CurrentVersion.targets(1217,5):
error MSB3644: The reference assemblies for .NETFramework,Version=v4.5.2 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 [C:\app\InventoryInterface\InventoryInterface1.csproj]
0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.15
The command 'cmd /S /C dotnet build Inventory.sln -c Release -o /out' returned a non-zero code: 1

I am new to windows container and I would like to know how to fix this. I already tried to curl the framework but when I execute it, nothing happens.

Thanks in advance.

1
  • You have to show the contents of InventoryInterface1.csproj. Commented May 10, 2022 at 20:28

1 Answer 1

1

Your app targets .NET Framework 4.5.2 (the version of .NET that's Windows only) and your SDK container is .NET 5.0, the multiplatform version of .NET.

You need to either migrate your application to .NET 5.0 (or 6.0) or build using mcr.microsoft.com/dotnet/framework/sdk instead. I couldn't find version 4.5.2 of the .NET Framework SDK as a container. The oldest one listed here is 4.6.2 so you'll have to move to (at least) that.

I'll recommend migrating to .NET 5/6, since .NET Framework isn't being actively developed anymore. Migrating also lets you run on both Windows and Linux. If you stay on .NET Framework, you have to stay on Windows.

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

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.