Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not find runtime target for framework .NETCoreApp=v1 compatible with one of the target runtimes

Tags:

asp.net

I am trying to migrate an Asp.Net Core RC1 project to RC2 and have been following this documentation and have also followed the instructions for DNX migration to .NET CLI.

I am getting the following error when I try dotnet run:

Can not find runtime target for framework '.NETCoreAPP, Version=v1.0' compatible with one of the target runtimes: 'win10-x64, win81-x64, win8-x64, win7-x64'. Possible causes:

  1. The project has not been restored or restore failed -run 'dotnet restore'
  2. The project does not list one of 'win10-x64, win81-x64, win7-x64' in the 'runtimes'

I have run dotnet restore and it seems to have completed successfully.

I have updated all the relevant packages to RC2.

like image 446
Blake Mumford Avatar asked Jun 02 '16 11:06

Blake Mumford


3 Answers

I should have done exactly what the error message said. When migrating from RC1, I did not realise that I had to specify a runtimes section in my project.json file.

In my project.json I added the following section:

"runtimes": {
    "win10-x64": { }
  }

And I was good to go.


Update 27 February 2017

New project templates in Visual Studio 2017 RC no longer require run times to be specified (in project.json or .csproj) in advance if you choose to deploy your app as a Framework Dependent Deployment (FDD).

If, however, you choose to deploy your app using Self-contained Deployment (SCD), then you will need to specify all the run times you want your app to run on in advance in your .csproj file.

Below is an example of a .csproj file for an app that uses the SCD deployment method:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
    <VersionPrefix>1.0.0</VersionPrefix>
    <DebugType>Portable</DebugType>
    <RuntimeIdentifiers>win10-x64;osx.10.11-x64</RuntimeIdentifiers>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
  </ItemGroup>
</Project>

Please see this link for more information, which includes a thorough description of both types of deployment options, as well as their benefits and disadvantages.

like image 56
Blake Mumford Avatar answered Oct 25 '22 02:10

Blake Mumford


I received this error after updating VS2015 core template to 1.0.1. It was because I have a PCL that targets netstandard 1.4 if you don't want to have to specify each runtime, Just change the dependency markup for Microsoft.NETCore.App to this:

"Microsoft.NETCore.App": {
 "type": "platform",
 "version": "1.0.1"
}
like image 76
Mike_G Avatar answered Oct 25 '22 01:10

Mike_G


in project.json I changed this (added type):

//"Microsoft.NETCore.App": "1.1.0",
"Microsoft.NETCore.App": { "version": "1.1.0", "type": "platform" },

Now I can build again :-)

update: now I can build again but not "run" the website.

You need to make sure you have the runtime and sdk also:

*) Visual Studio tools include .NET Core 1.0.1. To add .NET Core 1.1 support you need to also install the .NET Core 1.1 runtime.

https://www.microsoft.com/net/download/core#/current

like image 35
juFo Avatar answered Oct 25 '22 02:10

juFo