VS2015 与 dotnet-core cli 不兼容

VS2015 not compatible with dotnet-core cli

我无法使 VS2015 使用 dotnet cli - 我想使用 VS2015 编辑和测试可能的 dotnet-core 项目,然后能够使用 dotnet cli 编译 & 运行 它。然而,我所有的尝试都没有成功,这并不理想——我希望在 Windows 上编写代码,然后使用 Travis-Ci 进行构建。

这就是正在发生的事情:

VS2015 -> Dotnet 客户端

如果我为 net-core 创建 VS2015“控制台应用程序”项目(目标 .Net Framework 4.6.1),我得到以下 project.json

{
  "version": "1.0.0-*",
  "description": "ConsoleAppTest Console Application",
  "authors": [ "Nemo" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
  },

  "commands": {
    "ConsoleAppTest": "ConsoleAppTest"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Console": "4.0.0-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  }

这个项目可以编译,运行在 VS2015 使用时也很好。 但由于网络核心点是跨平台兼容性,我想通过 dotcore cli 恢复和构建它(例如,do CI build on Travis-ci)。 当 运行ning dotnet restore 在此项目中时,出现以下错误:

log  : Restoring packages for {my_path}\Projects\ConsoleAppTest\src\ConsoleAppTest\project.json...
error: System.Console 4.0.0-beta-23516 provides a compile-time reference assembly for System.Console on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.Threading 4.0.11-beta-23516 provides a compile-time reference assembly for System.Threading on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.Dynamic.Runtime 4.0.0 provides a compile-time reference assembly for System.Dynamic.Runtime on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.Linq.Expressions 4.0.0 provides a compile-time reference assembly for System.Linq.Expressions on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.IO 4.0.0 provides a compile-time reference assembly for System.IO on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.Threading.Tasks 4.0.0 provides a compile-time reference assembly for System.Threading.Tasks on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: System.Text.Encoding 4.0.0 provides a compile-time reference assembly for System.Text.Encoding on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
error: Some packages are not compatible with DNXCore,Version=v5.0 (win7-x64).
error: System.Console 4.0.0-beta-23516 provides a compile-time reference assembly for System.Console on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.Threading 4.0.11-beta-23516 provides a compile-time reference assembly for System.Threading on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.Dynamic.Runtime 4.0.0 provides a compile-time reference assembly for System.Dynamic.Runtime on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.Linq.Expressions 4.0.0 provides a compile-time reference assembly for System.Linq.Expressions on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.IO 4.0.0 provides a compile-time reference assembly for System.IO on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.Threading.Tasks 4.0.0 provides a compile-time reference assembly for System.Threading.Tasks on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: System.Text.Encoding 4.0.0 provides a compile-time reference assembly for System.Text.Encoding on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
error: Some packages are not compatible with DNXCore,Version=v5.0 (win7-x86).
info : Committing restore...
log  : Restore failed in 520ms.

Errors in {my_path}\Projects\ConsoleAppTest\src\ConsoleAppTest\project.json
    System.Console 4.0.0-beta-23516 provides a compile-time reference assembly for System.Console on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
    System.Threading 4.0.11-beta-23516 provides a compile-time reference assembly for System.Threading on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
    System.Dynamic.Runtime 4.0.0 provides a compile-time reference assembly for System.Dynamic.Runtime on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
    System.Linq.Expressions 4.0.0 provides a compile-time reference assembly for System.Linq.Expressions on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
    System.IO 4.0.0 provides a compile-time reference assembly for System.IO on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
    System.Threading.Tasks 4.0.0 provides a compile-time reference assembly for System.Threading.Tasks on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
    System.Text.Encoding 4.0.0 provides a compile-time reference assembly for System.Text.Encoding on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x64.
    Some packages are not compatible with DNXCore,Version=v5.0 (win7-x64).
    System.Console 4.0.0-beta-23516 provides a compile-time reference assembly for System.Console on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
    System.Threading 4.0.11-beta-23516 provides a compile-time reference assembly for System.Threading on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
    System.Dynamic.Runtime 4.0.0 provides a compile-time reference assembly for System.Dynamic.Runtime on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
    System.Linq.Expressions 4.0.0 provides a compile-time reference assembly for System.Linq.Expressions on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
    System.IO 4.0.0 provides a compile-time reference assembly for System.IO on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
    System.Threading.Tasks 4.0.0 provides a compile-time reference assembly for System.Threading.Tasks on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
    System.Text.Encoding 4.0.0 provides a compile-time reference assembly for System.Text.Encoding on DNXCore,Version=v5.0, but there is no run-time assembly compatible with win7-x86.
    Some packages are not compatible with DNXCore,Version=v5.0 (win7-x86).

NuGet Config files used:
    {another_path}\AppData\Roaming\NuGet\NuGet.Config

Feeds used:
    https://api.nuget.org/v3/index.json

尝试在 Ubuntu 14.04 Trusty in Travis CI 上尝试 dotnet 恢复时出现相同的错误,但除了 win7-x86 被替换为 Ubuntu。

Dotnet CLI -> VS2015

如果我使用 dotnet new 命令创建一个新项目,我会得到以下 project.json:

{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },

    "dependencies": {
        "NETStandard.Library": "1.0.0-rc2-23811"
    },

    "frameworks": {
        "dnxcore50": { }
    }
}

dotnet 命令中的 运行 时,这个项目编译并且 运行 很好。 但我想让它与 VS2015 一起工作,因为它非常舒服 IDE – 所以我打开 project.json 作为一个项目,一切似乎都在工作(在 dependenci 中没有冲突或错误es 所示)。

我将命令条目添加到 json:“commands”: { “ConsoleAppTest2”: “ConsoleAppTest2”} 并按 CTRL+F5 - 因此我遇到以下错误:

System.IO.FileLoadExpection: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definiton does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    at System.Reflection.RuntimeAssembly.GetEntryPoint(RuntimeAssembly assembly, ObjectHandleOnStack retMethod)
    at System.Reflection.RuntimeAssembly.get_EntryPoint()

我刚开始使用 net-core,不知道如何解决这个问题。 我担心这可能与使用旧版本的 dotnet 核心的 VS2015 有关(打开 dotnet 新创建的项目时,恢复包的 VS2015 输出包含以下行: C:\Users\{user}\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin\dnx.exe)。 如果这很重要,我在安装 VS2015 很久之后就从 msi.install 安装了 dotnet cli。

统计数据

我认为可能有用的统计数据:

OS: Windows 10 x64 恩

VS: Visual Studio Enterprise 2015 版本 14.0.25123.00 更新 2(我更新了所有建议的更新)

运行宁dnx --version的结果: Microsoft .NET 执行环境 版本:1.0.0-rc1-16609 类型:CoreClr 架构:x64 OS 姓名:Windows OS版本:10.0 运行时 ID:win10-x64

运行宁where dnx的结果: C:\Users{{用户}}.dnx\runtimes\dnx-coreclr-win-x64.1.0.0-rc1-update2\bin\dnx.exe

运行宁dnvm version的结果:1.0.0.rc1-15540

运行宁where dnvm的结果: C:\Users{{用户}}.dnx\bin\dnvm.cmd C:\程序Files\MicrosoftDNX\Dnvm\dnvm.cmd

运行宁dotnet --version的结果: .NET 命令行工具 (1.0.0-beta-001598)

Product Information:
 Version:     1.0.0-beta-001598
 Commit Sha:  7582649f88

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 Runtime Id:  win10-x64

运行宁where dotnet的结果: C:\程序Files\dotnet\bin\dotnet.exe

您的假设是正确的。 VS 中的工具还不是最新的。就在两周前,Microsoft 为 dotnet CLI 发布了 visual studio 工具的内部版本。 RC1(基于 VS2015.2 dnx 的工具)和尚未发布的新 dotnet CLI 之间发生了很多变化。

等两周。 RC2 即将推出,很可能带有工具支持。