简体   繁体   English

是否可以发布ASP.NET 5应用程序,以便目标计算机不需要安装DNX?

[英]Can an ASP.NET 5 application be published such that the target machine doesn't need DNX installed?

From the wiki for the main "aspnet" GitHub repo : 来自维基的主要“aspnet”GitHub回购

" 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... ". DNX是一个SDK,包含构建和运行应用程序所需的所有位,包括Core CLR中的CLR。它可以与您的应用程序一起进行bin部署...... ”。

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. 基于此描述以及我在Microsoft公告和博客文章中看到的其他评论,您似乎可以使用ASP.NET 5应用程序并创建一个没有外部依赖关系的自包含bundle。 The bundle would include your code, the DNX runner, the ~11 megabyte CoreCLR, and any other NuGet dependencies you might use. 该捆绑包将包含您的代码,DNX运行程序,~11兆字节CoreCLR以及您可能使用的任何其他NuGet依赖项。 "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. 但是,当我使用dnu publish ,情况并非如此。 The resulting bundle contains my code, and DLL's for the pieces of the standard library that I'm actually using. 生成的包包含我的代码,以及我实际使用的标准库部分的DLL。 However, it's not pulling in the whole CoreCLR... and it's certainly not pulling in DNX. 然而,它并没有拉动整个CoreCLR ......而且肯定不会引入DNX。 The run command from my project.json file gets turned into a run.cmd batch file that looks like this: 我的project.json文件中的run命令变成了一个run.cmd批处理文件,如下所示:

@"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. ...建议DNX预计已经安装在目标系统上,在此捆绑之外。

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. 如果您需要在目标系统上安装DNX,那么我不确定这种方法有什么优势。 Is there an additional step that one can take, to publish a bundle that has DNX and CoreCLR fully baked-in and self-contained? 是否可以采取额外步骤,发布具有DNX和CoreCLR完全烘焙和自包含的捆绑包?

I see that dnu publish has an optional --native argument, but I'm not sure that this is relevant. 我看到dnu publish有一个可选的--native参数,但我不确定这是否相关。 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 ". 当我使用“clr”时,我收到错误消息“ Native image generation is only supported for .NET Core flavors ”。 When I use "coreclr", I get this ugly stacktrace: 当我使用“coreclr”时,我得到了这个丑陋的堆栈跟踪:

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). 从理论上讲,您应该能够将应用程序部署到甚至没有安装.NET Framework的计算机中,但我记得听说即使dnxcore今天也有一些.NET Framework依赖,并且稍后会消失(我可能会弄错,值得一试)尝试这个)。

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. 假设存在并且您希望实现此目的,您应该使用--runtime开关,并且如果要将active值作为值传递,则需要激活coreclr。

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. 这应该将运行时与应用程序捆绑在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在ASP.NET 5 dnx中构建控制台应用程序 - Unable to build a console application in ASP.NET 5 dnx ASP.NET 5 DNX问题 - ASP.NET 5 DNX issue 创建新的ASP.net 5 MVC Web应用程序时,DNX Core和DNX 4.5始终不可用 - DNX Core and DNX 4.5 always out of reference when creating a new ASP.net 5 MVC Web Application 我无法使用Asp.Net MVC 6和DNX启动项目 - I can not start the project with Asp.Net MVC 6 and DNX 如何使用Asp.net Web应用程序访问客户端计算机上安装的客户端应用程序(扫描仪或.exe) - how to access client application (Scanner or .exe) which are installed on client machine using Asp.net web application dnx ef 7与asp.net的迁移错误 - dnx ef 7 migration error with asp.net ASP.NET 5发布的输出不提供来自wwwroot的文件 - ASP.NET 5 published output doesn't serve files from wwwroot 如何使用 asp.net Web 应用程序在本地计算机上显示和打开已安装的应用程序 - How to display and open installed applications on local machine using asp.net web application 如何在生产和开发环境中始终如一地获取ASP.NET 5 DNX项目的应用程序基础路径? - How to consistently get application base path for ASP.NET 5 DNX project on both production and development environment? 已发布的Web应用程序部署中的部分ASP.NET WEB - Partial ASP.NET WEB FROM Published Web Application Deployment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM