Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 599
Roman Pokrovskij Avatar asked Jan 02 '17 21:01

Roman Pokrovskij


People also ask

How do I change a target framework to a net core project?

Right click on the project in solution explorer, select properties, and go to the application tab. You will see that the correct framework is selected in target framework. If you want to target a different version, for example, an older version of . NET Standard for a library, you change that here.


2 Answers

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).

like image 187
Roman Pokrovskij Avatar answered Oct 18 '22 03:10

Roman Pokrovskij


The safest option, if you have a few files, is to just add a new project with the correct framework. Then copy the files from the old project across. This will stop you having build and other issues.

.NET Core for example has its own class library, console and test types.

.NET Core for example has its own class library, console and test types.

like image 35
Basil Avatar answered Oct 18 '22 02:10

Basil