2

.Net Core 2.2 application cannot find appsettings path when using "InProcess" hosting model on one of my systems, it only works when hosting model is changed to "OutOfProcess", is there a reason why the same application requires different configuration for different machines

I'm creating a new micro service and my application runs fine in PROD/QA/DEV servers with hosting model configured as "InProcess". when running in Debug mode its breaking because it couldn't find the appsettings path. I tried through second machine it works fine through second machine with hosting model as "InProcess". I'm I missing any configuration? which is making it work differently on different systems?!

App is using a Nuget for logging, when called that Nuget it reads the "RollingFile" path from the calling applicaton. Here the problem is on some of the machines it couldn't find the appsettings path while using "InProcess" hosting!!

Shashi sk
  • 21
  • 1
  • Did you tell your web app where to look? There's nothing special about `appsettings.json`, it's just a JSON file. It could be named `Elephant.json` and ASP.NET Core wouldn't care as long as you specified its path in the configuration method – Panagiotis Kanavos May 14 '19 at 14:23
  • yes I configured the builder using AddJsonFile extension method – Shashi sk May 14 '19 at 14:25
  • 2
    In the `InProcess` model the application is IIS. The working directory for that application is the location of the IIS executable. Any relative paths will use that directory as the working directory. That's why in-process examples specify a different working directory with `.SetBasePath(AppContext.BaseDirectory)`. This sets the working directory to the main dll's location – Panagiotis Kanavos May 14 '19 at 14:26
  • checked its not working out for me, I was using `.SetBasePath(hostingEnvironment.ContentRootPath) earlier. The only way I can make it work was by running it through Kestrel instead of IIS by using "OutOfProcess" hosting model – Shashi sk May 14 '19 at 14:34
  • What is the value of `hostingEnvironment.ContentRootPath` during debugging? You said yourself that InProcess *works* - both in production and QA. The published folder structure though isn't the same as your *project'*s folder structure. JSON files won't be copied to the debug folders unless you set their build action to `Copy Always` or `Copy if Newer`. – Panagiotis Kanavos May 14 '19 at 15:11
  • I Understand your point but what I'm trying to mention is, for some reason the same application builder configuration cannot find the appsettings file on few systems, it is breaking only on few systems, am I missing something related to IIs configuration – Shashi sk May 14 '19 at 18:14
  • this is a known bug and is due to be fixed in 3.0 – JimmyShoe Aug 07 '19 at 12:42
  • Looks like this issues was fixed as part of 2.2.2 – Shashi sk Aug 08 '19 at 13:48

0 Answers0