Convert .Net Core to .Net Framework

asp.net.Netasp.net Core.Net Framework-Version

asp.net Problem Overview


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

asp.net Solutions


Solution 1 - asp.net

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 - asp.net

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 - asp.net

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 - asp.net

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.

Solution 5 - asp.net

There are several steps that you need to do, in order to achieve this.

  1. Firstly right click on the .csproj file and add the following

   <TargetFrameworks>netstandard2.0;netcoreapp2.0;net35;</TargetFrameworks>
        <RuntimeIdentifiers>win7-x86;win7-x64</RuntimeIdentifiers> <EnableDefaultCompileItems>false</EnableDefaultCompileItems>

  1. Once you have made these changes reload the project and build it.
  2. This will generate the .dll files and Nuget package for this build in the Debug/Release folder of the project.
  3. Add these .dll to the nuget and access these projects from nuget.

Try the above steps. This should work.

Solution 6 - asp.net

In my version of Visual Studio 2017 (15.6.2) after 'Unloading the Project', right-clicking and selecting 'Edit <your project file>, I had to:

  1. Add the node:

    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>

  2. Delete the nodes:

    <TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>

    <TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.16299.0</TargetPlatformVersion>

    <TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>

    <ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Solution 7 - asp.net

My .net standard project is relatively simple with few Nuget packages. I just changed

<TargetFramework>netstandard2.0</TargetFramework>

TO

<TargetFramework>**net461**</TargetFramework> under PropertyGroup section of .csproj file and this did the job for me.. Thanks to Brandon Barkley for your answer in the comments.

Solution 8 - asp.net

add below in csproj

  <PropertyGroup>
    <TargetFrameworks>netcoreapp2.1;net471</TargetFrameworks>
  </PropertyGroup>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRichard WattsView Question on Stackoverflow
Solution 1 - asp.netAlexanderView Answer on Stackoverflow
Solution 2 - asp.netGreg GumView Answer on Stackoverflow
Solution 3 - asp.netJoshua SchlichtingView Answer on Stackoverflow
Solution 4 - asp.netBrandon AhearnView Answer on Stackoverflow
Solution 5 - asp.netSai KiranView Answer on Stackoverflow
Solution 6 - asp.netVorTechSView Answer on Stackoverflow
Solution 7 - asp.netPawanView Answer on Stackoverflow
Solution 8 - asp.netlemonView Answer on Stackoverflow