我如何 运行 针对 dnx451 测试我的 dnx50 项目?

How do I run tests on my dnx50 project against dnx451?

对于我的一个项目,我需要将 entity framework 从 7 降级到 6,为此,我需要使用 dnx451,而不是 dnx50(我认为这就是它的工作原理,我认为 451 是低于 50 的 .net 吗?idk)。

任何人,对于那个项目,我有一个我提取到它自己的项目的依赖项,称为 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 将在配置中查找该框架,但找不到。