无法在dotnet还原中解析runtime.ubuntu

时间:2017-01-23 20:35:25

标签: .net nuget .net-core

我的Windows 7机器上安装了dotnet 1.0.0-preview2-003131。当我在.NET Core项目的目录中使用cmd运行命令dotnet restore时,我收到以下错误:

log  : Restoring packages for C:\Projects\TestDotNetCore\Test2\project.json...
error: Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.DotNetHostP
olicy (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
error: Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.Runtime.Cor
eCLR (>= 1.0.4)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
error: Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.DotNetHostR
esolver (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
error: Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.Jit (>= 1.0
.4)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
error: Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System (>= 1.0
.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
error: Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System.Net.Sec
urity (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
error: Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System.Securit
y.Cryptography (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
error: Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System.Net.Htt
p (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
error: Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.DotNetHost
(>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
error: Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System.IO.Comp
ression (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
log  : Lock file has not changed. Skipping lock file write. Path: C:\Projects\Te
stDotNetCore\Test2\project.lock.json
log  : C:\Projects\TestDotNetCore\Test2\project.json
log  : Restore failed in 1315ms.

Errors in C:\Projects\TestDotNetCore\Test2\project.json
    Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.DotNetHostPoli
cy (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
    Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.Runtime.CoreCL
R (>= 1.0.4)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
    Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.DotNetHostReso
lver (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
    Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.Jit (>= 1.0.4)
' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
    Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System (>= 1.0.1)
' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
    Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System.Net.Securi
ty (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
    Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System.Security.C
ryptography (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
    Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System.Net.Http (
>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
    Unable to resolve 'runtime.ubuntu.16.04-x64.Microsoft.NETCore.DotNetHost (>=
 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.
    Unable to resolve 'runtime.ubuntu.16.04-x64.runtime.native.System.IO.Compres
sion (>= 1.0.1)' for '.NETCoreApp,Version=v1.0 (ubuntu.16.04-x64)'.

我的project.json看起来像这样:

{
    "version": "1.0.0-*",
    "buildOptions": {
        "debugType": "portable",
        "emitEntryPoint": true
    },

    "dependencies": {
        "Microsoft.NETCore.App": {
            "version": "1.0.1"
        }
    },
    "frameworks": {
        "netcoreapp1.0": {
            "imports": "dnxcore50"

        }
    },
    "runtimes": {
        "win7-x64": {},
        "ubuntu.16.04-x64": {}
    }
}

1 个答案:

答案 0 :(得分:1)

删除runtimes文件的project.json部分,或至少删除ubuntu.16.04-x64行。

除非您构建self-contained application,否则您不需要runtimes部分。