@glennc Was running into an issue when migrating to msbuild where WebHostBuilder.UseContentRoot was called with the wrong path which did not contain any appsettings.json file. This was difficult to diagnose since there were no logs to explain the 404 responses (which happened to be caused by missing .cshtml files). Once the logging was enabled, the traces made it easy to track down the bad UseContentRoot argument.
appsettings.json should not be optional in the template since it is already included in the template. The second call to AddJsonFile for appsettings.{env.EnvironmentName}.json will still demonstrate how to use the optional parameter.
A startup exception like System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The physical path is 'C:\...\src\WebApplication1\appsettings.json'. would have made @glennc's issue much easier to resolve.
@glennc Was running into an issue when migrating to msbuild where
WebHostBuilder.UseContentRoot
was called with the wrong path which did not contain any appsettings.json file. This was difficult to diagnose since there were no logs to explain the 404 responses (which happened to be caused by missing .cshtml files). Once the logging was enabled, the traces made it easy to track down the badUseContentRoot
argument.appsettings.json should not be optional in the template since it is already included in the template. The second call to
AddJsonFile
for appsettings.{env.EnvironmentName}.json will still demonstrate how to use the optional parameter.A startup exception like
System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional. The physical path is 'C:\...\src\WebApplication1\appsettings.json'.
would have made @glennc's issue much easier to resolve.