9
votes

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 -

enter image description here

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 -

enter image description here

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 ?

1
It seems you have VS 2019 Preview installed. Otherwise .Net Core 3.0 won't be in your list. Have you tried to download not preview version and check there?OlegI
@OlegI, The VS is "not preview" version, and I have installed .Net Core 3.0 Preview 7 myself.atiyar
Ensure you allow usage of preview .NET Core versions in Tools > Options > Environment > Preview Features if you want to use them. You then change the project version by editing the TargetFramework(s) element of the csproj. You can also right-click the project, choose Properties, and select another Target Framework from the combo box if you prefer this UI, but editing the csproj instead has become a well-defined developer task with .NET Core.Ray
@RayKoopa, I know how to manually change framework version. Previous versions of VS had an option to select framework version when you are selecting a Class Library template, for both .NET Framework and .NET Core. That's what I'm looking for.atiyar

1 Answers

1
votes

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:

Project properties

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.