Assuming you use template defaults
public static void Main()
{
var host = new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.Build();
}
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json");
}
- Source/ <=== Directory.GetCurrentDirectory(), IHostingEnvironment.ContentRootPath
- MyApp.csproj
- appsettings.json
+ wwwroot/ <=== IHostingEnvironment.WebRootPath
- bin/
- Debug/
+ netcoreapp2.0/ <=== AppContext.BaseDirectory
Shell location:
$ cd publishDir/
- publishDir/ <=== Directory.GetCurrentDirectory(), IHostingEnvironment.ContentRootPath. AppContext.BaseDirectory
- MyApp.dll
- appsettings.json
+ wwwroot/ <=== IHostingEnvironment.WebRootPath
During development, you don't need to copy wwwroot
to bin/Debug/netcoreapp2.0.
During development, you can change *.js files without needing to restart the server.
After publish, all content unifies to the same directory.
This requires launching dotnet MyApp.dll
from the correct directory.