CI/CD .Net Core 3.0

Hi, how can I tell explicitly to use .net core 3.0 to build the project on CI/CD? It tries to use 2.2 and fails

.gitlab-ci.yml
image : mcr.microsoft.com/dotnet/core/sdk:3.0
stages:

  • build
    variables:
    ASPNETCORE_ENVIRONMENT: “Development”
    before_script:
  • “cd Delivery”
    build:
    stage: build
    script:
  • “dotnet build”

Build FAILED.

/usr/share/dotnet/sdk/2.2.402/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. [/builds/flextrela/delivery/Delivery/Delivery.csproj]
0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.36
ERROR: Job failed: exit code 1

1 Like

I was getting that error too. I’ve been trying different images… at the moment, image: mcr.microsoft.com/dotnet/core/sdk:3.0 is working for my .NET Core 3.0/Standard 2.2 solution. I don’t know what I did. I tried that same exact image a few minutes ago and it was failing with the same error you are getting. I’d be curious to see what your console output is while it is building.

What are your first few lines? Mine are:

Running with gitlab-runner 12.5.0-rc1 (b295d93b) on docker-auto-scale 0277ea0f Using Docker executor with image mcr.microsoft.com/dotnet/core/sdk:3.0 ... Pulling docker image mcr.microsoft.com/dotnet/core/sdk:3.0 ... Using docker image sha256:170a7f2ec51a5cd1f6e68a3142ebb78f92949543f4d62f3851b97a0d124c606c for mcr.microsoft.com/dotnet/core/sdk:3.0 ... Running on runner-0277ea0f-project-15263587-concurrent-0 via runner-0277ea0f-srm-1573615210-54c6aad8... Fetching changes with git depth set to 50...

Edit: Ah apparently I was using microsoft/dotnet/core/sdk:3.0 the first time rather than what I mentioned above. So I’m not sure I ever got the error you are getting aside from that first build where it was still using microsoft/dotnet:latest. Are you still having this issue? I would guess not/Microsoft fixed the image.

1 Like

I’m looking to link up with others using .net with GitLab, would either of you be happy to chat and share some best practices etc?

Thanks!