找不到与目标运行时之一兼容的框架.NETCoreApp = v1的运行时目标 [英] Can not find runtime target for framework .NETCoreApp=v1 compatible with one of the target runtimes
问题描述
我正在尝试将Asp.Net Core RC1项目迁移到RC2,并且一直在关注文档,并且还遵循了 DNX迁移到.NET CLI的说明.
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.
尝试dotnet run
时出现以下错误:
找不到框架'.NETCoreAPP,版本= v1.0'的运行时目标 与以下目标运行时兼容:'win10-x64,win81-x64, win8-x64,win7-x64".可能的原因:
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:
- 项目尚未还原或还原失败-运行'dotnet restore'
- 该项目未在运行时"中列出"win10-x64,win81-x64,win7-x64"之一
我已经运行了dotnet restore
,它似乎已成功完成.
I have run dotnet restore
and it seems to have completed successfully.
我已将所有相关软件包更新为RC2.
I have updated all the relevant packages to RC2.
推荐答案
我应该完全按照错误消息的意思进行操作.从RC1迁移时,我没有意识到必须在project.json
文件中指定runtimes
部分.
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.
在我的project.json
中,添加了以下部分:
In my project.json
I added the following section:
"runtimes": {
"win10-x64": { }
}
我很好走.
更新2017年2月27日
如果选择将应用程序部署为Framework Dependent Deployment
(FDD),则Visual Studio 2017 RC中的新项目模板不再需要预先指定运行时间(在project.json
或.csproj
中).
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).
但是,如果您选择使用Self-contained Deployment
(SCD)部署应用,则需要在.csproj
文件.
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.
以下是使用SCD部署方法的应用程序的.csproj
文件的示例:
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.
这篇关于找不到与目标运行时之一兼容的框架.NETCoreApp = v1的运行时目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!