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

时间:2016-01-15 12:19:56

标签: c# .net dnx

对于我的一个项目,我需要将实体框架从7降级到6,为了做到这一点,我需要使用dnx451而不是dnx50(我认为无论如何这都是如此,我认为451是.net一个低于50?idk)。

Anywho,对于那个项目,我有这个依赖项,我提取到它自己的项目,名为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,来自红宝石世界)

1 个答案:

答案 0 :(得分:1)

dnx451

你不小心错过了那里的框架版本。它应该是 451 (正如您在问题中多次正确提到的那样),而不是541.所以,因为您使用jQuery(document).ready(function () { jQuery('ul').sortable({ stop: function (event, ui) { var data = jQuery(this).sortable('toArray'); jQuery('#elements-order').val(data); } }); }); 框架(在错误消息中指定)运行它, DNX将在配置中查找该框架,但无法找到它。