title: Can an ASP.NET 5 application be published such that the target machine doesn't need DNX installed?
body: <p>From the <a href="https://github.com/aspnet/Home/wiki">wiki for the main "aspnet" GitHub repo</a>: </p>
  
  <blockquote>
    <p>"<em>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...</em>".</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>However, when I use <code>dnu publish</code>, 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 <code>run</code> command from my <code>project.json</code> file gets turned into a <code>run.cmd</code> batch file that looks like this:</p>
  
  <pre><code>@"dnx.exe" --appbase "%~dp0approot\src\ConsoleApplication" Microsoft.Framework.ApplicationHost run %*
  </code></pre>
  
  <p>... suggesting that DNX is expected to already be installed on the target system, outside of this bundle.</p>
  
  <p><strong>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?</strong></p>
  
  <p>I see that <code>dnu publish</code> has an optional <code>--native</code> 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, "<code>Native image generation is only supported for .NET Core flavors</code>".  When I use "coreclr", I get this ugly stacktrace:</p>
  
  <pre><code>C:\Users\Steve\Desktop\ConsoleApplication&gt;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' ---&gt; 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.&lt;&gt;c.&lt;Create&gt;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.&lt;&gt;c__DisplayClass3_2.&lt;Main&gt;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)
  </code></pre>