Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create an SDK style project for a .net framework 4.7.2 project in using visual studio?

I am running the latest version of VS2019 16.6.1 Yet the new project wizard for a windows class library still creates the old style project.

I want to use this method to research this problem

I found some help on converting framework projects here but not on creating new ones from scratch.

like image 273
Kirsten Avatar asked Oct 20 '25 10:10

Kirsten


1 Answers

The simplest approach in my experience is to create a .NET Core/Standard project for whatever type of application you want (e.g. console or class library) and then edit the csproj file by hand. (You can edit the csproj file by just double clicking on the project in Visual Studio, if it's an SDK-style project.)

So as a concrete example, to create a .NET 4.7.2 class library, I'd choose "Class Library (.NET Standard)" from the list of project templates. That creates a project file like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

</Project>

Just edit the project to specify the target framework you actually want - so for .NET 4.7.2 you'd use:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>
</Project>

(I tend to tidy up the XML at the same time removing the blank lines like that, but you don't have to of course :)

like image 186
Jon Skeet Avatar answered Oct 23 '25 00:10

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!