title: .Net Core on Linux runs fine with 'dotnet myapp.dll' but fails with systemctl
body: <p>I am trying to host an ASP.Net Core MVC application on Ubuntu Server 16.04 LTS by following the directions in <a href="https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.1&amp;tabs=aspnetcore2x" rel="nofollow noreferrer">this tutorial</a>.</p>
  
  <p>From the Linux machine, I use <code>git pull</code> to pull in my project.  I build it successfully with <code>dotnet build</code>, which triggers a package restore.  I publish it successfully with <code>dotnet publish -c Release -r linux-x64</code>.  I change directories to <code>bin/Release/netcoreapp2.1</code> and run <code>sudo cp ./*.* /var/aspnetcore/myapp/</code> to copy the files into the directory where I am hosting the project.  I navigate to that directory and type <code>dotnet myapp.dll</code> - the app begins listening on ports 5000 and 5001, and from a different computer, I can type my domain name into a browser and see the web site, which means the Nginx reverse proxy and Kestrel must be working fine.</p>
  
  <p>Now I want to run the application as a service so that it starts with the computer, restarts on crash, logs errors, etc, but when I type <code>sudo systemctl start kestrel-myapp.service</code> it crashes immediately and attempts to restart every 10 seconds but fails.  The log shows the error: <code>An assembly in the application dependencies manifest (myapp.deps.json) was not found: package: 'Microsoft.EntityFrameworkCore.Relational.Design', version '1.1.5' path: 'lib/netstandard1.3/Microsoft.EntityFrameworkCore.Relational.Design.dll' Main process exited, code=exited, status=140/n/a</code></p>
  
  <p>So, the version 1.1.5 looks suspiciously low, but I updated all of my NuGet packages and it still wants to use it.  Plus, I don't understand why it doesn't crash with <code>dotnet myapp.dll</code> if there is a problem with the dependencies.  Does anybody know how to fix the issue?</p>
  
  <p>Here is my service file:</p>
  
  <pre><code>[Unit]
  Description=myapp ASP.Net Core MVC Application
  
  [Service]
  WorkingDirectory=/var/aspnetcore/myapp
  ExecStart=/usr/bin/dotnet /var/aspnetcore/myapp/myapp.dll
  Restart=always
  # Restart service after 10 seconds if the dotnet service crashes:
  RestartSec=10
  SyslogIdentifier=myapp
  User=www-data
  Environment=ASPNETCORE_ENVIRONMENT=Production
  Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>Bonus question: where do I copy my wwwroot folder with my static files to?  The application runs but can't find any of my javascript or css files, and I'm not sure where they belong.</p>