我在使用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
您知道如何解决此错误吗?
答案 0 :(得分:0)
解决!
我试图在根文件夹中执行dnx . test
,而不是Test Project文件夹。
答案 1 :(得分: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创建的,这就是您需要导航到目录或指定路径的方式。
希望这有帮助!