Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert a .NET Core project to a .NET Framework project?

I created a "Console App (.NET Core)" project in Visual Studio. Now I need to add a dependency that only works on .NET Framework 4.6+, not .NET Core.

Is there a way to convert my project to a full .NET Framework project?


Here's what I've tried:

I went to the project properties and attempted to change the project framework, but I don't see the option I need in the dropdown:

Only .NETCoreApp displays in the target framework list.

If I click "Install other frameworks..." I'm taken to a page that says .NET Framework versions are included in Visual Studio 2017 -- which is exactly what I'm using to edit this project. This is where I got stuck.

like image 720
Steve Trout Avatar asked May 04 '17 16:05

Steve Trout


People also ask

Can we run the .NET Core project in .NET Framework?

In order to run ASP.NET Core Apps on the . NET Framework it needs to only reference . Core NuGet packages which contains only the . NET Standard 2.0 builds.

Is .NET Framework the same as .NET Core?

NET Framework is a platform for . NET applications on Windows whereas, NET Core is the latest version of the . NET Framework which is a cross-platform and open-source framework optimized for modern app needs and developer workflows.


1 Answers

If you're happy with it still using the new tooling, the easiest approach is probably just to edit the project file (csproj). Right-click on the project in Solution Explorer and you should have a context menu option of "Edit <yourproject>.csproj". Click on that, and just change

<TargetFramework>netcoreapp1.1</TargetFramework> 

to

<TargetFramework>net46</TargetFramework> 

... and I suspect you'll be good to go. (It may confuse VS for a little while as it restores appropriate packages etc.)

like image 50
Jon Skeet Avatar answered Nov 08 '22 23:11

Jon Skeet