可以在ASP.NET 5应用程序发布,使得目标机器不需要安装DNX? [英] Can an ASP.NET 5 application be published such that the target machine doesn't need DNX installed?

查看:341
本文介绍了可以在ASP.NET 5应用程序发布,使得目标机器不需要安装DNX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

维基的主要ASPNETGitHub库

  

的DNX是包含所有建设所需的位并运行SDK   一个应用程序,其中包括在核心CLR的情况下,在CLR。有可能   仓部署与应用程序... 的。

我在什么这实际上意味着有点糊涂了。在此基础上的描述,我已经看到在微软宣布和博客等的意见,这似乎是你可以采取一个ASP.NET 5应用程序并创建一个独立的包,没有外部依赖性。该包将包括你的code,对DNX亚军的〜11兆字节CoreCLR,你可以使用任何其他的NuGet依赖。 ,准备所有运行应用程序所需的位被丢弃到一个干净的石板目标机器。

然而,当我使用 DNU发布,这是不会发生什么变化。由此产生的软件包包含我的code和DLL文件的标准库是我实际使用件。但是,它不拉在整个CoreCLR ......它肯定不拉的DNX。该运行从我的 project.json file命令被变成了 run.cmd 的批处理文件,看起来像这样:

  @dnx.exe--appbase%〜dp0approot的\ src \ ConsoleApplicationMicr​​osoft.Framework.ApplicationHost跑%*
 

...表明DNX预期已经被目标系统上安装,该束的外侧。

我在这里丢失一些基本的东西?如果您需要安装在目标系统上DNX,那么我不知道这个方法提供什么优势可言。是否有额外的步骤,一个可以拿,发布一个包,有DNX和CoreCLR全面的烤机和自足?

我看到 DNU发布有一个可选的 - 本地的说法,但我不知道这是相关的。这样的说法让你指定一个运行。当我用CLR我得到错误信息,本机图像生成仅支持.NET的核心味道。当我使用coreclr,我得到这个丑陋的堆栈跟踪:

  C:\ Users \用户史蒂夫\桌面\ ConsoleApplication> DNU发布--native --runtime活跃
System.IO.FileNotFoundException:找不到无法加载文件或程序集Microsoft.Framework.Project,版本= 1.0.0.0,文化=中性公钥= null或它的一个依赖。该系统找不到指定的文件。
文件名:Microsoft.Framework.Project,版本= 1.0.0.0,文化=中性公钥=空'---> System.IO.FileNotFoundException:找不到无法加载指定的文件。
文件名:Microsoft.Framework.Project
   在System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(的AssemblyName的AssemblyName)
   在System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr的gchManagedAssemblyLoadContext,的AssemblyName的AssemblyName)
   在Microsoft.Framework.PackageManager.Publish.NativeImageGenerator.<>c.<Create>b__4_0(String R)
   在System.Linq.Lookup`2.Create [TSource](IEnumerable`1源,Func`2的KeySelectors,Func`2 elementSelector,IEqualityComparer`1比较器)
   在System.Linq.GroupedEnumerable`3.GetEnumerator()
   在System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   在System.Linq.Enumerable.Any [TSource](IEnumerable`1源)
   在Microsoft.Framework.PackageManager.Publish.NativeImageGenerator.Create(PublishOptions选项,PublishRoot根,IEnumerable`1上下文)
   在Microsoft.Framework.PackageManager.Publish.PublishManager.Publish()
   在Microsoft.Framework.PackageManager.Program&LT;&GT;。c__DisplayClass3_2&lt;主&GT; b__4()
   在Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute(字串[] args)
   在Microsoft.Framework.PackageManager.Program.Main(字串[] args)
System.IO.FileNotFoundException:找不到无法加载指定的文件。
文件名:Microsoft.Framework.Project
   在System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(的AssemblyName的AssemblyName)
   在System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr的gchManagedAssemblyLoadContext,的AssemblyName的AssemblyName)
 

解决方案

在理论上,你应该能够将应用程序部署到未安装甚至.NET Framework中的一个机器,但我记得听到,即使是dnxcore有一些。 .NET框架依赖今天将在后面走了(我可能是错误的,这是值得尝试了这一点)。

假设这是存在的,要做到这一点,你的确应该使用 - 运行时开关,你需要有,如果你要通过coreclr主动有效的值。

例如:

  dnvm使用1.0.0-BETA4 -r coreclr -p
 

活动版本运行架构位置铝
                                                                             IA
                                                                             小号
------ ------- ------- -------- ------------  - 
       1.0.0-BETA4 CLR 64 C:\ Users \用户Tugberk \ .dnx \运行时间
       1.0.0-BETA4 CLR 86 C:\ Users \用户Tugberk \ .dnx \运行时间
       1.0.0-BETA4 coreclr 64 C:\ Users \用户Tugberk \ .dnx \运行时间
  * 1.0.0-BETA4 coreclr 86 C:\ Users \用户Tugberk \ .dnx \运行时间

这应该捆绑的旁边你的应用程序的运行。

From the wiki for the main "aspnet" GitHub repo:

"The DNX is an SDK containing all of the bits needed to build and run an application, including the CLR in the case of Core CLR. It can be bin deployed with your application...".

I'm a bit confused on what this actually means. Based on this description, and other comments I've seen in Microsoft announcements and blog posts, it would seem that you could take an ASP.NET 5 application and create a self-contained bundle with no outside dependencies. The bundle would include your code, the DNX runner, the ~11 megabyte CoreCLR, and any other NuGet dependencies you might use. "All the bits needed to run your application", ready to be dropped onto a clean slate target machine.

However, when I use dnu publish, that's not what happens. The resulting bundle contains my code, and DLL's for the pieces of the standard library that I'm actually using. However, it's not pulling in the whole CoreCLR... and it's certainly not pulling in DNX. The run command from my project.json file gets turned into a run.cmd batch file that looks like this:

@"dnx.exe" --appbase "%~dp0approot\src\ConsoleApplication" Microsoft.Framework.ApplicationHost run %*

... suggesting that DNX is expected to already be installed on the target system, outside of this bundle.

Am I missing something fundamental here? If you need DNX installed on the target system, then I'm not sure what advantages are provided by this approach at all. Is there an additional step that one can take, to publish a bundle that has DNX and CoreCLR fully baked-in and self-contained?

I see that dnu publish has an optional --native argument, but I'm not sure that this is relevant. That argument wants you to specify a runtime. When I use "clr" I get the error message, "Native image generation is only supported for .NET Core flavors". When I use "coreclr", I get this ugly stacktrace:

C:\Users\Steve\Desktop\ConsoleApplication>dnu publish --native --runtime active
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Framework.Project, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Framework.Project, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.IO.FileNotFoundException: Could not load the specified file.
File name: 'Microsoft.Framework.Project'
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at Microsoft.Framework.PackageManager.Publish.NativeImageGenerator.<>c.<Create>b__4_0(String r)
   at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`3.GetEnumerator()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
   at Microsoft.Framework.PackageManager.Publish.NativeImageGenerator.Create(PublishOptions options, PublishRoot root, IEnumerable`1 contexts)
   at Microsoft.Framework.PackageManager.Publish.PublishManager.Publish()
   at Microsoft.Framework.PackageManager.Program.<>c__DisplayClass3_2.<Main>b__4()
   at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute(String[] args)
   at Microsoft.Framework.PackageManager.Program.Main(String[] args)
System.IO.FileNotFoundException: Could not load the specified file.
File name: 'Microsoft.Framework.Project'
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)

解决方案

In theory, you should be able to deploy your application into a machine where even .NET Framework is not installed but I remember hearing that even the dnxcore has some .NET Framework dependencies today and will be gone later (I could be mistaken, it's worth trying this out).

Assuming this is there and you want to achieve this, you should indeed use the --runtime switch and you need to have coreclr active if you are going to pass active as value.

For example:

dnvm use 1.0.0-beta4 -r coreclr -p

Active Version           Runtime Architecture Location                       Al
                                                                             ia
                                                                             s
------ -------           ------- ------------ --------                       --
       1.0.0-beta4       clr     x64          C:\Users\Tugberk\.dnx\runtimes
       1.0.0-beta4       clr     x86          C:\Users\Tugberk\.dnx\runtimes
       1.0.0-beta4       coreclr x64          C:\Users\Tugberk\.dnx\runtimes
  *    1.0.0-beta4       coreclr x86          C:\Users\Tugberk\.dnx\runtimes

This should bundle the runtime along side your application.

这篇关于可以在ASP.NET 5应用程序发布,使得目标机器不需要安装DNX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆