所以我正在尝试构建一个自包含的.NetCore应用程序,只是一个简单的默认hello世界应用程序。
我按照Scott Hanselman's示例了解了如何在搜索答案后创建应用程序。
所以我在我的project.json
中有这个代码{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
//"type": "platform",
"version": "1.1.0"
}
},
"imports": "dnxcore50",
"runtimes": {
"win10-x64": {},
"osx.10.10-x64": {},
"ubuntu.14.04-x64": {}
}
}
}
}
正如您所看到的,我已经注释掉了类型行,并为每个平台添加了运行时。
但我一直收到这个错误:
Can not find runtime target for framework '.NETCoreApp,Version=v1.1' compatible with one of the targe
t runtimes: 'osx.10.10-x64'. Possible causes:
1. The project has not been restored or restore failed - run `dotnet restore`
2. The project does not list one of 'osx.10.10-x64' in the 'runtimes' section.
3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute li
braries.
现在我在Mac上运行它,但是在ubuntu上发生了同样的错误,但是报告了与ubuntu相关的错误。
我的dotNet版本= 1.0.0-preview2-1-003177
我有点陷入困境,一切似乎都指向它应该工作的事实,这可能是我忽视的一件明显的事情。
感谢任何帮助。
答案 0 :(得分:2)
我认为您需要将json的结构更改为:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.1.0"
}
}
}
},
"runtimes": {
"win10-x64": {},
"osx.10.10-x64": {},
"ubuntu.14.04-x64": {}
}
}
差异很大,runtimes
部分不在 framework
部分。
确保在更改project.json后运行dotnet restore --no-cache
。