首页 新闻 会员 周边

.net core中build项目时出错:Can not find runtime target for framework '.NETCoreApp,Version=v1.1'

0
悬赏园豆:30 [已解决问题] 解决于 2016-12-11 12:10

无论用 dotnet build 命令还是用 Visual Studio 在 build 一个 .net core 项目时总是出现下面的错误提示:

Can not find runtime target for framework '.NETCoreApp,Version=v1.1' compatible with one of the target runtimes: '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 '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.

请问如何解决这个问题?

dudu的主页 dudu | 高人七级 | 园豆:30994
提问于:2016-12-09 16:02
< >
分享
最佳答案
0
收获园豆:30
CodeHsu | 大侠五级 |园豆:5468 | 2016-12-09 18:52

的确是project.json中runtimes配置的问题。

在同事的Windows 10电脑可以正常build,出现这个问题的电脑是Windows Server 2012。

project.json中的runtimes是这么写的:

"runtimes": { 
  "win10-x64": {},
  "osx.10.11-x64": {},
  "ubuntu.14.04-x64": {}
}

加上"win8-x64",重新dotnet restore之后问题就解决了。

"runtimes": {
  "win10-x64": {},
  "win8-x64": {},
  "osx.10.11-x64": {},
  "ubuntu.14.04-x64": {}
}
dudu | 园豆:30994 (高人七级) | 2016-12-11 11:59
其他回答(4)
0

.net core 本机上的sdk版本是1.1的吗 ?我今天也遇到了找不到 .net core 版本的问题 后来把本机上的 dotnet core ask 那些都都升级到最新版就好了



BUTTERAPPLE | 园豆:3190 (老鸟四级) | 2016-12-09 23:17
0

1.10的sdk没安装。下载安装就好了。

czd890 | 园豆:14412 (专家六级) | 2016-12-10 10:08
0

可以试试把自动产生的project.lock.json删掉,然后再编译:D

dax.net | 园豆:380 (菜鸟二级) | 2016-12-10 16:06
0

还没有用过net core,感觉落伍了

飞刀软件 | 园豆:204 (菜鸟二级) | 2016-12-10 16:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册