In Visual Studio 2019 if I try to create an ASP.NET Core web application project, I get to select the framework version in the following screen -
But when I try to create a .NET Core class library project I am prompted with the following screen which does not provide any option for selecting the framework version -
Clicking the Create button always creates the project right away taking the latest .NET Core version installed on my machine.
So, how can I select the framework version while creating the class library project? Or do I have to change it manually every time after creation ?
NET Core, you need to use the . NET Framework. You can now reference . NET Framework libraries from .
The ASP.NET project creation dialog providing a framework selection seems to be an exception in .NET Core / Standard projects to me. At least since VS2019 with the new "New Project" dialog, you have the following options after creating the project with this dialog.
"Normally" (to my experience), you right-click the project file in the Solution Explorer, choose "Edit Project File" and modify the <TargetFramework>
element by naming one of the valid target framework monikers. See MSDN about them.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
You can also rename the element to TargetFrameworks
(note the pluralized name) to build against multiple frameworks at the same time, which are ;
separated:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net451;netstandard2.0;netcoreapp3.0</TargetFrameworks>
</PropertyGroup>
</Project>
Alternatively, you can also choose "Properties" from the project right-click menu and select a framework via a slightly dated UI not supporting all of the new csproj features, like said multi targeting:
If you need many new projects building against a specific framework, create a template csproj and just copy and rename it.
Also, if you want to build against preview versions of .NET Core in non-preview versions of VS, ensure you allow usage of them in Tools > Options > Environment > Preview Features
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With