无法解决 dnx 处的依赖项错误。测试

Failed to resolve dependencies error at dnx . test

我正在使用 Xunit 测试的 ASP.NET 5 和 MVC 6 项目中工作,但是当我尝试执行 dnx . test 时出现此错误:

dnx : System.InvalidOperationException: Failed to resolve the following dependencies for target framework 'DNX,Version=v4.5.1':
At line:1 char:1
+ dnx . test
+ ~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (System.InvalidO...ersion=v4.5.1'::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

   Microsoft.CSharp 4.0.0-beta-23019
   System.Collections 4.0.10-beta-23019
   System.Linq 4.0.0-beta-23019
   System.Runtime 4.0
.10-beta-23019
   System.Threading 4.0.10-beta-23019
   xunit 2.1.0-beta4
   xunit.runner.dnx 2.1.0-beta4

Searched Locations:
  D:\Project\{name}\project.json
  D:\Project\MrBellhop.Test\src\{name}\project.json
  D:\Project\MrBellhop.Test\test\{name}\project.json
  C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\{name}.dll
  C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\{name}.dll
  C:\Windows\Microsoft.NET\assembly\GAC_32\{name}\{version}\{name}.dll
  C:\Windows\Microsoft.NET\assembly\GAC_64\{name}\{version}\{name}.dll
  C:\Windows\Microsoft.NET\assembly\GAC_MSIL\{name}\{version}\{name}.dll

Try running 'dnu restore'.

   at Microsoft.Framework.Runtime.DefaultHost.GetEntryPoint(String applicationName)
   at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
   at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at dnx.host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
   at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
   at dnx.host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
>     + CategoryInfo          : NotSpecified: (System.InvalidO...ersion=v4.5.1'::String) [], RemoteException
>     + FullyQualifiedErrorId : NativeCommandError

我已经关注 this manual,虽然我实现了一个简单的示例,但我得到了同样的错误。

我的project.json

{
  "version": "1.0.0-*",
  "description": "Project.Test",
  "authors": [ "" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "dependencies": {
    "System.Collections": "4.0.10-beta-23019",
    "System.Linq": "4.0.0-beta-23019",
    "System.Threading": "4.0.10-beta-23019",
    "System.Runtime": "4.0.10-beta-23019",
    "Microsoft.CSharp": "4.0.0-beta-23019",
    "xunit": "2.1.0-beta4-*",
    "xunit.runner.dnx": "2.1.0-beta4-*"
  },
  "commands": {
    "test": "xunit.runner.dnx"
  },
  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  }
}

我正在使用 Asp.net 5 Beta 6

你知道如何解决这个错误吗?

已解决!

我试图在根文件夹而不是测试项目文件夹中执行 dnx . test

我也遇到了最困难的时候。我发现路径也是区分大小写的。

示例:

PM> cd src
PM> cd busweb
PM> dnx . ef
dnx : System.InvalidOperationException: Unable to resolve project 'busweb' from C:\Users\scoll\Google Drive\Clients\MECCSoft\BusWeb\src\busweb

但是...

PM> cd..
PM> cd BusWeb
PM> dnx . ef

                     _/\__
               ---==/    \
         ___  ___   |.    \|\
        | __|| __|  |  )   \\
        | _| | _|   \_/ |  //|\
        |___||_|       /   \\/\

 7.0.0-beta5-13549

项目创建为 BusWeb,这就是您需要导航到目录或指定路径的方式。

希望对您有所帮助!