I have 2 apps, one console one web api both .net core v2.0 . Both has the same problem.
I used to run my application thru source files. I was building and running them on a linux machine. Everything was good, everything was great, but now i'm running the same app thru publish output.
Now it doesn't work as it suppose to, because the app can't read appsettings.json.
configuration["Settings:Port"] != null
? int.Parse(configuration["Settings:Port"]) //i should be getting this - 1234
: default(int) //but instead i got this - 0
I have corrupted the appsettings.json file and i was expecting to see an exception but, nothing. Just nothing. I checked the file a couple of times, i modified the file a couple of times just because i was desperate. Nothing. Nothing happens, nothing changes.
I tried debug-build, i tried release-build, i tried to change build action of that file... I tried this, i tried that... Nothing works and i have no idea why.
And as you can guess, i need a few advices. Thank you all.
Edit:
How i use/read config file:
IConfiguration configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", true, true).Build();