I’m currently learning microservices with .Net Core. As part of this I’ve been following one of Microsoft’s tutorials: https://dotnet.microsoft.com/learn/aspnet/microservice-tutorial
It has all been pretty straight forward, however I hit an error when attempting to run docker build:
—> Running in 734e82e92c23
/usr/share/dotnet/sdk/2.2.207/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0. [/src/myMicroservice.csproj]
The command ‘/bin/sh -c dotnet restore’ returned a non-zero code: 1
Updating the Dockerfile references seems to have resolved the issue. I replaced each occurrence of 2.2 with 3.0 and re-ran the following command:
My complete docker file was as follows:
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
COPY myMicroservice.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c release -o /app
COPY –from=build /app .
ENTRYPOINT [“dotnet”, “myMicroservice.dll”]
Full source available here: https://github.com/Buzzology/myMicroservice