Dotnet new specify version
When creating a new.NET project using the dotnet new
command, you can specify the version of the.NET framework or runtime to use.
Here are a few ways to specify the version:
-
Using the
-f
option: You can use the-f
option followed by the framework version you want to use. For example:dotnet new console -f netcoreapp3.1
This will create a new console application project targeting.NET Core 3.1.
-
Using the
--framework
option: You can use the--framework
option followed by the framework version you want to use. For example:dotnet new console --framework net5.0
This will create a new console application project targeting.NET 5.0.
-
Using the
--runtime
option: You can use the--runtime
option followed by the runtime version you want to use. For example:dotnet new console --runtime netcoreapp2.2
This will create a new console application project targeting.NET Core 2.2.
-
Using the
--sdk-version
option: You can use the--sdk-version
option followed by the SDK version you want to use. For example:dotnet new console --sdk-version 5.0.100
This will create a new console application project targeting.NET 5.0.100.
Note that the available versions may vary depending on your.NET installation and the SDKs installed on your machine.
Also, you can check the available versions by running the command dotnet --list-sdks
or dotnet --list-runtimes
.