簡體   English   中英

如何針對dnx451在dnx50項目上運行測試?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM