我有一个 DNXCore5 应用程序,我一直非常小心地只针对 DNXCore。无论如何,我可以通过很少的步骤将它发布到 Windows Server 2012 R2。我正在尝试在 Ubuntu 中做同样的事情。我已经设置了我的环境并复制了我已发布的项目,我使用 Kestrel 作为 Web 服务器,因此它在 Windows 上与在 Linux 上相同。
我已经设置了 dnvm 并且运行时的 beta 5 安装得很好。然后,我通过以下方式将 Visual Studio 创建的红隼脚本标记为可执行文件,
chmod +x 红隼
现在我无法运行 kestrel 脚本,因为最后一行失败了,因为它试图启动一个不存在的 dnx 本地副本(出于某种原因)。
exec "$DIR/approot/runtimes/dnx-coreclr-win-x64.1.0.0-beta5/bin/dnx" --appbase "$DNX_APPBASE" Microsoft.Framework.ApplicationHost kestrel "$@"
所以我修改了最后一行,这样它就变成了,
dnx --appbase "$DNX_APPBASE" Microsoft.Framework.ApplicationHost kestrel "$@"
仅键入 dnx 表明它使用了正确的框架,因为我得到以下输出,
Microsoft .NET Execution environment Mono-x64-1.0.0-beta5-12103
Usage: dnx [options]
Options:
--appbase <PATH> Application base directory path
--lib <LIB_PATHS> Paths used for library look-up
--debug Waits for the debugger to attach before beginning execution.
-?|-h|--help Show help information
--version Show version information
--watch Watch file changes
--packages <PACKAGE_DIR> Directory containing packages
--configuration <CONFIGURATION> The configuration to run under
--port <PORT> The port to the compilation server
现在,当我通过 ./kestrel 启动 kestrel 脚本时,我得到了,
System.InvalidOperationException: The current runtime target framework is not compatible with 'MyApp'.
Current runtime Target Framework: 'DNX,Version=v4.5.1 (dnx451)'
Type: Mono
Architecture: x64
Version: 1.0.0-beta5-12103
Please make sure the runtime matches a framework specified in project.json
at Microsoft.Framework.ApplicationHost.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at dnx.host.Bootstrapper.RunAsync (System.Collections.Generic.List`1 args, IRuntimeEnvironment env) [0x00000] in <filename unknown>:0
我正在努力寻找知道如何摆脱这个错误的人,如果我在 Visual Studio 解决方案资源管理器中为我的项目(Web 应用程序和类库)打开引用节点,我并不是针对完整框架,他们都只有一个“DNX Core 5.0”节点,而且他们都在项目属性部分中定位它。我不知道它应该从哪里得到这个参考。我的 project.json 文件如下,
库
"dependencies": {
},
"frameworks": {
"dnxcore5": {
"dependencies": {
"System.Collections": "4.0.10-beta-23019",
"System.Runtime": "4.0.20-beta-23019",
"Microsoft.CSharp": "4.0.0-beta-23019"
}
}
}
网络应用
"dependencies": {
"Microsoft.Framework.ConfigurationModel": "1.0.0-beta5",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta5",
"Microsoft.AspNet.Mvc": "6.0.0-beta5",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
"Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
"Microsoft.Framework.Logging": "1.0.0-beta5",
"Microsoft.Framework.Logging.Console": "1.0.0-beta5",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5",
"Newtonsoft.Json": "7.0.1",
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-beta5",
"System.Security.Cryptography.DeriveBytes": "4.0.0-beta-23019",
"MyLib": "1.0.0-*",
"Kestrel": "1.0.0-beta5"
},
"frameworks": {
"dnxcore5": {
"dependencies": {
"System.Runtime.Extensions": "4.0.10-beta-23019",
"System.Collections": "4.0.10-beta-23019",
"System.Runtime": "4.0.20-beta-23019",
"Microsoft.CSharp": "4.0.0-beta-23019",
"System.Private.Networking": "4.0.0-beta-23109",
"System.Net.Security": "4.0.0-beta-23109"
}
}
},
我什至确定我只是使用 Kerstrel 进行托管。有任何想法吗?我完全被困住了。