[英]How do I run tests on my dnx50 project against dnx451?
对于我的一个项目,我需要将实体框架从7降级到6,为了做到这一点,我需要使用dnx451而不是dnx50(我认为那是可行的方式,我认为451是.net低于50?
任何人,对于该项目,我都具有提取到其自己项目中的该依赖项,称为csharp_extensions,并且该依赖项是我想同时使用dnx50和dnx451的东西。
这是我本地csharp_extensions中的project.json:
{
"version": "1.1.0",
"configurations": {
"Debug": {
"compilationOptions": {
"define": [ "DEBUG", "TRACE" ]
}
},
"Release": {
"compilationOptions": {
"define": [ "RELEASE", "TRACE" ],
"optimize": true
}
}
},
"dependencies": {
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final",
"System.Reflection": "4.1.0-beta-*",
"xunit": "2.1.0-*",
"xunit.runner.dnx": "2.1.0-*"
},
"commands": {
"run": "csharp_extensions",
"test": "xunit.runner.dnx"
},
"frameworks": {
"dnx541": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
},
"dnxcore50": {
"_": "this is the recommended windows runtime",
"dependencies": {
"System.Console": "4.0.0-beta-*",
"System.Reflection.TypeExtensions": "4.1.0-beta-*",
"System.Runtime.Extensions": "(4.0,]",
"System.Dynamic.Runtime": "(4.0.0,]",
"Microsoft.CSharp": "(4.0.0,]",
"System.IO": "(4.0,]"
}
}
},
}
这是有效的project.json(尽管仅适用于dnx50) https://github.com/NullVoxPopuli/csharp-extensions/blob/master/project.json与上面粘贴的内容相同,但dnx541没有条目。
使用上面的(粘贴的)project.json,当我尝试构建时,它说一切都成功了,但是当测试运行时,出现以下错误:
------ Discover test started ------
------ Test started: Project: csharp-extensions ------
Starting Microsoft.Dnx.TestHost [C:\Users\me\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe --appbase "C:\Users\me\Development\csharp-extensions" Microsoft.Dnx.ApplicationHost --port 32182 Microsoft.Dnx.TestHost --port 36832 --parentProcessId 21136]
System.InvalidOperationException: The current runtime target framework is not compatible with 'csharp-extensions'.
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)'
Version: 1.0.0-rc1-16231
Type: Clr
Architecture: x86
OS Name: Windows
OS Version: 6.3
Runtime Id: win81-x86
Please make sure the runtime matches a framework specified in project.json
at Microsoft.Dnx.ApplicationHost.DefaultHost.GetEntryPoint(String applicationName)
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, BootstrapperContext bootstrapperContext)
at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, BootstrapperContext bootstrapperContext)
Unable to start Microsoft.Dnx.TestHost
========== Discover test finished: 0 found (0:00:01.0852529) ==========
我对dnvm还是很陌生,就我而言,这些命令对我来说意义不大(尽管我很习惯rvm,但来自ruby世界)
"frameworks": {
"dnx541": {
…
您不小心将那里的框架版本弄错了。 它应该是451 (正如您在问题中多次提到的那样),而不是541。因此,由于您是使用dnx451
框架(如错误消息中所指定)运行的,因此DNX将在配置中寻找该框架,但不能找到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.