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...".

我有点不明白这到底意味着什么.基于这个描述,以及我在微软公告和博客文章中看到的其他 comments ,你似乎可以 Select ASP.NET 5应用程序,并创建一个没有外部依赖项的自包含包.该Bundle 包将包括您的代码、DNX runner、~11MB的CoreCLR,以及您可能使用的任何其他NuGet依赖项."运行应用程序所需的所有信息",随时准备投入到一台干净的目标机器上.

然而,当我使用dnu publish时,情况并非如此.生成的包包含我的代码,以及我实际使用的标准库片段的DLL.然而,它并没有吸引整个CoreCLR...而且它肯定不会引入DNX.我的project.json文件中的run命令被转换为run.cmd批处理文件,如下所示:

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

... 表明DNX预计已经安装在目标系统上,不在该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?

我看到dnu publish有一个可选的--native参数,但我不确定这是否相关.该参数希望您指定运行时.当我使用"clr"时,我得到错误消息"Native image generation is only supported for .NET Core flavors".当我使用"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)

推荐答案

理论上,你应该能够将你的应用程序部署到一台机器上.NET Framework尚未安装,但我记得听说即使是dnxcore也有一些.NET框架的依赖关系现在就存在,稍后就会消失(我可能弄错了,值得一试).

假设这是存在的,并且您想要实现这一点,您确实应该使用--runtimeswitch ,并且如果您要将active作为值传递,则需要使coreclr处于活动状态.

例如:

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

这应该会将运行时与您的应用程序Bundle 在一起.

Asp.net相关问答推荐

在 lambda 表达式中否定 Func

System.Net.Http 版本冲突导致构建警告

VS2013发布Web部署任务失败文件正在使用中

如何在 IISExpress 上使用带有 localhost 的子域?

判断会话是否为空

IIS 6/ASP.NET Windows 身份验证 list ?

多行文本框多个换行符

'Microsoft.ACE.OLEDB.12.0' 提供程序未在本地计算机上注册.

MvcBuildViews true 与 ASP.NET MVC 2 中的实体框架

GridView 与嵌套类的属性绑定

如何在 C# 中转换 TryCast?

我的 asp.net mvc Web 应用程序中的 OutputCache 设置.防止缓存的多种语法

不能在 DropDownList 中 Select 多个项目

web.config 中与 targetFramework 相关的配置错误

为什么在 MVC4 Razor 布局文件中无法识别 @Scripts 和 @Styles 命令?

将 html 标记从 jquery 发布调用发送到 asp.net 页面时,从客户端检测到潜在危险的 Request.QueryString 值

为什么 Controls 集合不提供所有 IEnumerable 方法?

如何在服务器控件属性中使用 ASP.NET <%= 标签?

ASP.NET MVC3 局部视图命名约定

使用 FileUpload Control 获取文件的完整路径