title: Setting the correct execution directory (root path) in ASP.NET Core (Service/IIS)
body: <p>I'd like to publish my ASP.NET Core web app both targeting <em>netcoreapp2.0</em>, where it can run in a console environment or inside IIS or as a traditional <em>net462</em> app which allows running as console or Windows service. For this I need to set the correct root paths, but ASP.NET Core is still lacking documentation about it.</p>
  
  <p>Most examples fetch the root path using <code>Directory.GetCurrentDirectory()</code>, but there's also <code>PlatformServices.Default.Application.ApplicationBasePath</code> through the <a href="https://www.nuget.org/packages/Microsoft.Extensions.PlatformAbstractions/" rel="nofollow noreferrer" title="Microsoft.Extensions.PlatformAbstractions">Microsoft.Extensions.PlatformAbstractions</a> nuget package. One seems to provide the source directory, the other points to the execution directory.</p>
  
  <p>There's also the possibility to set both the <strong>Content Root</strong> and the <strong>Web Root</strong> for the <code>WebHostBuilder</code>, <strike>unfortunately I haven't found a proper explaination about their difference</strike> (<em>webroot is from where static content should be served, content root is the app directory</em>).</p>
  
  <p>What and how are the correct paths to be set in which scenario (...IIS, console) so that e.g. the ASP.NET Core infrastructure is able to pick up its files (config, static files, web pages)?</p>