How to change VS 2017 RC .csproj project's target framework (from core to classic)?

Roman Pokrovskij picture Roman Pokrovskij · Jan 2, 2017 · Viewed 23k times · Source

How to change target framework with VS 2017 RC in new core asp "csproj" projects?

I mean to change after project was created. There are no project.json file which was used for that in VS 2015. In project properties in targets "pull down" there are no other options then ".NETCoreApp 1.1" and ".NETCoreApp 1.0".

Details: I have used yoman to generate SPA project: http://blog.stevensanderson.com/2016/05/02/angular2-react-knockout-apps-on-aspnet-core/

so I was unable to select .NET Framework during the csproj creation. What to do now?

enter image description here

Answer

Roman Pokrovskij picture Roman Pokrovskij · Jan 3, 2017

Edit csproj file this way:

<TargetFramework>netcoreapp1.1</TargetFramework>

replace with:

<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>

and remove:

<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />

Then

dotnet restore
dotnet build

Optional:

dotnet run

Do not start dotnet run from Package Manager Console. It starts but it become impossible to stop web app with ctrl c (standard way).

If VS F5 doesn't work, (true for VS 2017 RC, core services generated with yoman templates), then change:

<OutputType>winexe</OutputType>

to

<OutputType>Exe</OutputType>

and restart VS, rebuild is not enough (to enable F5, again true for VS 2017 RC).