ASP.NET Core as Windows service wwwroot location
<p>I have a windows-service application containing ASP .NET Core</p>

<p>The project.json has 2 commans:</p>

<pre><code>"commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "service": "MyAppNamespace"
}
</code></pre>

<p>The entry point class:</p>

<pre><code>public class Program : ServiceBase
{
    IApplication _application;

    public Program(IServiceProvider serviceProvider)
    {

    }

    public void Main(string[] args)
    {
        Run(this);
    }

    protected override void OnStart(string[] args)
    {
        var configProvider = new MemoryConfigurationProvider();
        configProvider.Add("server.urls", "http://*:80");

        var config = new ConfigurationBuilder()
            .Add(configProvider)
            .AddEnvironmentVariables()
            .Build();

        _application = new WebHostBuilder(config)
            .UseServer("Microsoft.AspNet.Server.Kestrel")
            .UseStartup&lt;Startup&gt;()
            .Build()
            .Start();

        // my stuff bellow
    }

    protected override void OnStop()
    {
        _application?.Dispose();
    }
}
</code></pre>

<p>After publishing project we have this folder structure:</p>

<pre><code>approot
logs
wwwroot
</code></pre>

<p>Next I start my application from console</p>

<pre><code>dnx.exe -p "C:\MyProject\approot\src\MyProject" service
</code></pre>

<p>But instead of using webroot directory from "C:\MyProject\wwwroot" we have same as project.json i.e. "C:\MyProject\approot\src\MyProject"</p>

<p>If I start application by "web" command like this:</p>

<pre><code>dnx.exe -p "C:\MyProject\approot\src\MyProject" web
</code></pre>

<p>then all works as should, but of course my entry point was ignored and I cannot execute my stuff, neither run as service</p>

<p>project.json</p>

<pre><code>{
  "version": "1.0.0-*",

  "dependencies": {
    "MicroORM": "1.0.7",
    "Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Npgsql": "3.0.5",
    "ObjectPool": "1.0.0"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:80",
    "service": "MikroBill"
  },

  "frameworks": {
    "dnx46": {
      "frameworkAssemblies": {
        "System.Data": "4.0.0.0",
        "System.ServiceProcess": "4.0.0.0"
      }
    }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
  }
}
</code></pre>