Default .NET Core template is broken
Summary
The YML on the default .NET Core template is broken. The build stage of the YML fails. https://gitlab.com/jadentom/net-core-broken-template/-/jobs/1239974451
Steps to reproduce
- Create a project, selecting the ".NET Core" template https://gitlab.com/projects/new#create_from_template
- Run a pipeline on it from https://gitlab.com/<MY_GROUP_OR_USERPROFILE>/<PROJECT_NAME>/-/pipelines/new
Example Project
Project: https://gitlab.com/jadentom/net-core-broken-template/ Pipeline: https://gitlab.com/jadentom/net-core-broken-template/-/jobs/1239974451
What is the current bug behavior?
Build stage of pipeline fails
What is the expected correct behavior?
Entire pipeline succeeds
Relevant logs and/or screenshots
$ dotnet build
Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
/usr/share/dotnet/sdk/3.1.408/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(127,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 5.0. Either target .NET Core 3.1 or lower, or use a version of the .NET SDK that supports .NET Core 5.0. [/builds/jadentom/net-core-broken-template/dotnetcore.csproj]
Build FAILED.
/usr/share/dotnet/sdk/3.1.408/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(127,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 5.0. Either target .NET Core 3.1 or lower, or use a version of the .NET SDK that supports .NET Core 5.0. [/builds/jadentom/net-core-broken-template/dotnetcore.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.44
Output of checks
This bug happens on GitLab.com
Possible fixes
The bug happens because the default YML references docker image mcr.microsoft.com/dotnet/core/sdk:latest
. .NET Core development ends at 3.1, which means that this container has SDK 3.1 installed.
https://gitlab.com/jadentom/net-core-broken-template/-/blob/master/.gitlab-ci.yml#L1
On the other hand the .csproj references netcoreapp5.0
(.NET 5), which is the latest version of .NET that succeeds both .NET Core 3.1 and .NET Framework 4.8 (which is also why the "Core" was dropped). To build it, an SDK of 5.0 or later is required.
https://gitlab.com/jadentom/net-core-broken-template/-/blob/master/dotnetcore.csproj#L5
The docker image mcr.microsoft.com/dotnet/sdk:latest
should be used instead (note the absence of "core" in the URL). This docker image currently points to an image with SDK 5.0 installed and will be updated whenever the current .NET release changes.
Docker hub page: https://hub.docker.com/_/microsoft-dotnet-sdk
Announcement of move (see bottom of Details section for why /core/ points to 3.1) https://github.com/dotnet/dotnet-docker/issues/2375
On another note, the template could also use renaming to .NET (no core)