How could I create a webapi of the .NET 5 version using the dotnet cli?
Whenever I run the dotnet new webapi
I am getting the .NET Core 3.1 project. I have the .NET 5 installed locally. How could I make the .NET 5 a default version for the dotnet cli?
I tried running the
$ dotnet new webapi --framework "net5.0"
but it gives me an error:
Couldn't find an installed template that matches the input, searching online for one that does...
Here is the result of running the dotnet --info
:
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.301
Commit: 7feb845744
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.301\
Host (useful for support):
Version: 5.0.7
Commit: 556582d964
.NET SDKs installed:
3.1.301 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
dotnet new webapi -o projectName --framework "net5.0"
NB: Change projectName to the name of your project.