无论用 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.
请问如何解决这个问题?
缺少 runtime
节点?
Can not find runtime target for framework .NETCoreApp=v1 compatible with one of the target runtimes
的确是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": {} }
.net core 本机上的sdk版本是1.1的吗 ?我今天也遇到了找不到 .net core 版本的问题 后来把本机上的 dotnet core ask 那些都都升级到最新版就好了
1.10的sdk没安装。下载安装就好了。
可以试试把自动产生的project.lock.json删掉,然后再编译:D
还没有用过net core,感觉落伍了