Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...