VS2015与dotnet-core cli不兼容

时间:2016-05-04 10:35:10

标签: visual-studio-2015 windows-10 .net-core

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

所以这就是发生的事情:

VS2015 - > Dotnet cli

如果我为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恢复和构建它(例如,在Travis-ci上构建CI)。 在此项目中运行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

尝试在Tranet CI中的Ubuntu 14.04 Trusty上恢复它时,会出现同样的错误,但除了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作为一个项目,一切似乎都在工作(没有显示依赖关系中的冲突或错误)。

我将命令条目添加到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,并且不知道如何解决这个问题。 我担心它可能与VS2015使用旧版本的dotnet核心有关(在打开dotnet新创建的项目时,VS2015恢复包的输出包含以下行: C:\Users\{user}\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin\dnx.exe)。 如果这很重要,我在安装VS2015后很久就安装了msi.install的dotnet cli。

统计

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

操作系统:Windows 10 x64 En

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

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

运行where dnx 的结果:     C:\用户{{用户}} DNX \运行时\ DNX-coreclr赢-x64.1.0.0-RC1-UPDATE2 \ BIN \ dnx.exe

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

运行where dnvm 的结果:     C:\用户{{用户}} DNX \ BIN \ dnvm.cmd     C:\ Program Files \ Microsoft DNX \ 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:\ Program Files \ dotnet \ bin \ dotnet.exe

1 个答案:

答案 0 :(得分:1)

您的假设是正确的。 VS中的工具尚未更新。两周前,微软已经为dotnet CLI内部发布了visual studio工具。在RC1(基于VS2015.2 dnx的工具)和尚未发布的新dotnet CLI之间已经发生了很多变化。

等两周。 RC2即将推出,最有可能提供工具支持。