Convert .Net Core to .Net Framework
Solution 1
I have loaded core project to the VS 2017 RC Community and open *.csproj in text editor.
Just delete teg
<RuntimeFrameworkVersion>
and replace
<TargetFramework>netcoreapp1.1</TargetFramework>
to
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
And after all in project properties set to any another framework and reset back (VS reload and repair *.csproj file).
Solution 2
This worked for me in VS2017:
Start with .net core web project template.
Edit *.csproj so it looks like this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
</ItemGroup>
</Project>
Save and close.
Try running project.
The PackReferences is just the NuGet files, and you can add them through the GUI if the versions are different from mine above.
Solution 3
There's lots of similar answers here, but I didn't see one that was quite what I ended up doing, so I'd like to leave this here just in case someone else is in the same shoes.
Just to be clear, my project was a console program. So, if you're trying to use this answer for something else, your mileage may vary.
In your .csproj
file, inside of the <PropertyGroup></PropertyGroup>
tag, modify <TargetFramework>
to reflect the following:
<TargetFramework>net461</TargetFramework>
Now, in this example, I was using v4.6.1. I can only assume that you'll plug in your version behind the word "net", without the periods. Good luck!
Solution 4
None of the answers here worked for me. In .Net Core 2 the project.json file no longer exists. However, I did solve this problem using the following steps.
1) I removed all nuget packages from my existing project.
2) I created a separate .net core web app project, targeting .net 4.61. This was to get the default nuget packages.
3) I edited the temporary project's .csproj file, copied all the PackageReference nodes inside ItemGroup, and pasted them into my existing projects .csproj file.
4) Edited the TargetFramework node (inside PropertyGroup) from "netstandard2" to "net461"
I had a few package changes to track down and resolve, but otherwise I was able to run.
Richard Watts
Updated on July 08, 2022Comments
-
Richard Watts almost 2 years
I have a .Net Core project web project, and for various reasons want to convert it to a .Net Framework project.
Is there an easy way to do this, or do I have to start again and import the code from the previous projects
-
Nick Painter almost 7 yearsMy csproj file did not have the <RutimeFrameworkVersion> tag, but I followed the rest of these instructions and this still worked for my project.
-
Ms01 over 6 yearsThis doesn't work for me at all. What do you even mean by repair?
-
Alexander over 6 years@MarkusStenqvist- when you start VS "see" a new record in *.csproj file and create right structure inside
-
Alexander over 6 yearsRemeber - you should close VS - edit *.csproj file and only after start VS
-
Zaak over 6 years@Alexander there is no need to close VS, you can just unload the project and right click the project to edit .csproj file directly in VS and then load it again
-
Brandon Barkley over 6 yearsThis solution got me close enough, but I had some errors when building relating to inferring frameworks. It gave me what I needed in the GUI to actually be able to select a framework though. The actual line output was <TargetFramework>net461</TargetFramework> in Visual Studio after I was done.
-
person27 over 6 yearsThis failed to work for me and I had difficulty undoing it. Readers, I suggest backing up your .csproj files first.
-
Tony over 6 yearsNow, in 2017, in my case, I put net471
-
bvj about 6 years
-
Colm Bhandal about 5 years@Tony good spot. I'm now at 472. But it was inconsequential really, because once you make the change, you can edit it via the project properties in VS.
-
K.Oleksiak almost 5 yearsI did this and after this change the "Target Framework" in "Properies"is empty. Does this result in any negative conciquences? Am I missing something?
-
Alexander almost 5 years@K.Oleksiak - this is strange, usually after editing and starting VS make all work by himself. Have you started VS jet ?
-
Alexander almost 5 years@K.Oleksiak - and of course remember about this github.com/dotnet/standard/issues/514
-
ghostbust555 over 4 yearsThis worked perfectly, <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> did not. Not sure why
-
schlebe almost 4 yearsI develop in VB.Net on VisualStudio 2019 and I have use successfully the same technic on vbproj file. I have ONLY changed '<TargetFramework>netcoreapp3.1</TargetFramework>' to <TargetFramework>net472</TargetFramework>
-
Caleb W. over 2 yearsthanks for the actual answer