aspnet / Templates

This repo is OBSOLETE - please see the README file for information
Other
150 stars 57 forks source link

.AddJsonFile("appsettings.json"... should not be optional #685

Closed halter73 closed 7 years ago

halter73 commented 8 years ago

@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.