1

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.

Kirsten Greed
  • 11,170
  • 26
  • 117
  • 234

1 Answers1

3

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 :)

Jon Skeet
  • 1,261,211
  • 792
  • 8,724
  • 8,929
  • Do you by any chance have suggestions on getting a Microsoft.NET.Sdk.Web / full framework project starting in debug mode from Visual Studio? Can't figure out what to do with error: Unable to run your project. The "RunCommand" property is not defined. – Saul May 19 '21 at 18:19
  • @Saul: I'd expect it to just work - that's not an error I've seen before. – Jon Skeet May 19 '21 at 18:23
  • Was expecting it to just work as well but when using Sdk="Microsoft.NET.Sdk" it complains "The project doesn't know how to run the profile IIS Express." and when switching to Sdk="Microsoft.NET.Sdk.Web" the error changes into what I previously quoted. Looks as if some setting is missing from somewhere but so far I haven't been able to figure out what could it be or where. – Saul May 19 '21 at 18:30
  • For anyone else stumbling on the same issue - managed to fix it by following https://github.com/dotnet/sdk/issues/833#issuecomment-440228858 – Saul May 19 '21 at 19:05