如果我使用Visual Studio 2015 Update 3创建新的ASP.NET Core MVC应用程序,它运行得很好。但是,如果我使用所述应用并将其Nuget包更新到ASP.NET Core 1.0.1,我会收到以下构建错误:
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 cause
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, win8-x64, win7-x64' in the 'runtimes' section.
3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries.
这是一个错误,还是环境问题?
附录:
恢复中的日志看起来很好:
log : Restoring packages for <path to project>\project.json...
log : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in E:\Software Projects\subq\src\SubQ.API\project.json...
log : Lock file has not changed. Skipping lock file write. Path: <path to project>\project.lock.json
log : <path to project>\project.json
log : Restore completed in 6210ms.
project.json看起来像这样:
{
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.NETCore.App": "1.0.1"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
],
"runtimes": {
"win10-x64": {}
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
安装了最新的SDK。
答案 0 :(得分:5)
根据https://github.com/dotnet/core/issues/267: 当使用nuget进行更新时,“类型”:“平台”被删除,这有效地将项目更改为独立,因此将强制要求运行时段。
我手动将“type”:“platform”添加到project.json文件中解决了这个问题。
>>> arr = [1, 2, 4, 3]
>>> print(", " . join(arr))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected string, int found
>>> sarr = [str(a) for a in arr]
>>> print(", " . join(sarr))
1, 2, 4, 3
>>>
并且还要https://github.com/dotnet/core/issues/267: 通过NuGet UI更新调用项目系统以更新project.json,“type”:在编辑期间删除“platform”。 NuGet 3.5.0 RTM(尚未发布)将解决此问题。
答案 1 :(得分:3)
我认为runtimes
应该放在frameworks
设置之外。变化
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
],
"runtimes": {
"win10-x64": {}
}
}
},
到
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"runtimes": {
"win10-x64": {},
"win81-x64": {}
},
我还必须添加win81-x64
,因为我在Windows 8.1上运行,并且编译器抱怨它。
让我知道这是否有效!