58

Is it possible to create an SDK-style .NET Framework project in Visual Studio (to be more specific I use the latest VS2019)? Or does it still require manual manipulations?

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

I'm interested in creating a new project, not in migrating existing project from old .csproj file style to the new .csproj SDK-style. I've already edited .csproj files manually many times but it's super inconvenient.

7
  • 1
    All .NET Core and .NET Standard projects use the new project format. What are you trying to do? Create a .NET Framework project with the new format? Commented Jul 23, 2020 at 13:28
  • 1
    Sure, just create a new .NET Standard / .NET Core project, and change the <TargetFramework> Commented Jul 23, 2020 at 13:32
  • 1
    @PanagiotisKanavos Yes, I have to work with .net framework. And it's possible to use sdk style projects in .net framework. I wanted to know how to create such projects with VS. Now I have to edit csproj file manually Commented Jul 23, 2020 at 13:32
  • 2
    @isxaker I think it's just that there isn't a template for .NET Framework + SDK-style, but you can very easily use the .NET Core / Standard + SDK-Style template, and change a couple of characters to set the target to net48 or whatever Commented Jul 23, 2020 at 13:39
  • 1
    Yeah, but if you're using an SDK-style project you're going to be manually manipulating the csproj anyway (and VS makes this easy with SDK-style projects). Chances are that the template isn't using the right version of netstandard / netcoreapp, so you're going to be changing it regardless. It's just you'll change it from e.g. netstandard2.1 to net48, instead of e.g. netstandard2.1 to netstandard2.0 Commented Jul 23, 2020 at 13:43

3 Answers 3

52

We have to create a sdk-style .net framework project manually. By setting the TargetFramework to (for example) net472.

You can refer to the following steps to make it.

First, we need to create a Class Library (.NET Standard) project.

Second, we need to modify the csproj file.

The initial file:

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

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

</Project>

You can edit it to:

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

  <PropertyGroup>
     <TargetFramework>net472</TargetFramework>
  </PropertyGroup>

</Project>

Finally, you can get a sdk-style .net framework project.

enter image description here

Sign up to request clarification or add additional context in comments.

7 Comments

and in case i want to "upgrade" an existing (old) csproj file where i have all the includes... do I need to add them manually, too?
If you want to "upgrade" an existing .NET-Framework project to use the SDK style project format but still target .NET Framework you can use the dotnet-upgrade-assistant tool and exit after the "convert project to sdk style" step. See: dotnet.microsoft.com/en-us/platform/upgrade-assistant
I didn't even realize this was possible. Is there any reason why VS can't do this by default? Has this changed?
The old upgrade-assistant version (which is able to cancel after SDK style migration was done) can be installed with dotnet tool install --global upgrade-assistant --version 0.4.421302.
The new (0.5.261.51392) version of the upgrade-assistant has a special section specifically for sdk type upgrades so no need to "exit early" anymore. Just select "Upgrade project features"
|
19

Thanks to the comments on the previous answer which pointed to upgrade-assistant. Here are the commands I used:

Install the tool:

$ dotnet tool install -g upgrade-assistant

Then either run interactively and select "Upgrade project features > Convert project to SDK style (feature.sdkstyle)":

upgrade-assistant upgrade

Or do this in one-shot on the cli like this:

upgrade-assistant upgrade MyProj/MyProj.csproj -o feature.sdkstyle

1 Comment

The documentation for the upgrade-assistant CLI has moved. It can now be found here learn.microsoft.com/en-us/dotnet/core/porting/…
4

Easyest way for do that - just use template for .Net Core enter image description here

choose any framework.

enter image description here

When VS generate for you file *.csproj, open it by click mouse

enter image description here

delete 2 lines <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable>

and change TargetFramework to net48 (in case you use NetFramework 4.8) enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.