【发布时间】:2016-01-15 20:33:57
【问题描述】:
对于我的一个项目,我需要将实体框架从 7 降级到 6,为此,我需要使用 dnx451,而不是 dnx50(我认为无论如何都是这样,我认为 451 是.net 一个低于 50?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 世界)
【问题讨论】:
-
如果我使用 GitHub 上的那个项目并将
project.json更改为上面的那个,那会是你想要做的吗? -
是的,我只是想让项目与 dnx451 兼容,这样我就可以在我的其他项目中使用 EF6