2015-08-24 29 views
0

我用的xUnit測試一個ASP.NET 5和6 MVC項目的工作,但是當我嘗試執行dnx . test我得到這個錯誤:無法解決dnx中的依賴關係錯誤。測試

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測試版6

你知道如何解決這個問題?

+0

您可以分享'project.json'文件和'dnx的整個輸出。在設置DNX_TRACE = 1環境變量之後進行測試? –

+0

您使用的是什麼版本的DNX? [你可以不必再使用speficy的路徑](https://github.com/aspnet/Announcements/issues/52)。例如:嘗試'dnx測試'。 –

+0

dnx測試返回「請指定要運行的命令」 – unairoldan

回答

0

解決!

我試圖在根文件夾中執行dnx . test而不是Test Project文件夾。

0

我對此也是最難的一次。我發現路徑也是區分大小寫的。

例子:

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,那就是你需要如何導航到該目錄或指定的路徑爲好。

希望這會有所幫助!