title: ASP.NET 5 published output doesn't serve files from wwwroot
body: <p>I am having a great deal of trouble with the published version of my MVC 6 web application.  It works fine when running from Visual Studio, but when running from the published output the static files aren't being read from the wwwroot folder.</p>
  
  <p>I know I'm supposed to include code examples with my question.  It is a lot of code and involves comparing my solution in Visual Studio to the published output.  For my code example I've created a GitHub repo that reproduces this:
  <a href="https://github.com/TimothyK/Mvc6ServiceEg" rel="nofollow">https://github.com/TimothyK/Mvc6ServiceEg</a>.</p>
  
  <p>The project is basically File-New Project for an ASP.NET 5 Web Application.  However, eventually I want to get my project running as a self hosted Windows Service.  So there is a bit of code in this project that will eventually let it run as a Windows Service and manually calls the default Startup class.  This code was extracted from this article: <a href="http://taskmatics.com/blog/host-asp-net-in-a-windows-service/" rel="nofollow">http://taskmatics.com/blog/host-asp-net-in-a-windows-service/</a>.  The code creates a DNX command called "run" in addition to the default "web" command.</p>
  
  <p>As per the readme.md file the BuildScripts\Publish.bat file will create a self contained folder for the project to be run from. After running the Publish.bat script the self hosted web server can be run using C:\publish\Mvc6ServiceEg\approot\run.cmd.</p>
  
  <p>When running in this manner static files are not served up from the web server as expected. You can reproduce this by browsing to <a href="http://localhost:5000/images/Banner-02-VS.png" rel="nofollow">http://localhost:5000/images/Banner-02-VS.png</a>. That works fine if you run the web app from Visual Studio, but gets a 404 error if running from the published run.cmd file.</p>
  
  <p>I've figured out what is going wrong, but I don't know how to fix it.  The reason is that web server is not mapping to the correct folder. Static files should be hosted from the C:\publish\Mvc6ServiceEg\wwwroot folder, which does contain the images\Banner-02-VS.png file.</p>
  
  <p>The web server is actual hosting static files from C:\publishMvc6ServiceEg\approot\packages\Mvc6ServiceEg\1.0.0\root. You can prove that by browsing to <a href="http://localhost:5000/Project_Readme.html" rel="nofollow">http://localhost:5000/Project_Readme.html</a>, which does exist in that folder.</p>
  
  <p>There is a hosting.json file in the published output that should be telling the web server that the webroot is the wwwroot folder.  However, the run.cmd execution path of the web application doesn't seem to be respecting that.</p>
  
  <p>Can anyone tell me why this isn't mapping correctly?  Thanks in advance.</p>