Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can developers have different appsettings.development.json settings?

I have a main web application and a Web API application. (The first application calls the API of the second application.) When running locally, Visual Studio is configured to lauch both applications.

My appsettings.development.json file overrides the URL of the API website when running locally. This is working fine.

But now another developer is running these projects on his system. When he does, the URL of the API website is different than on my system.

How can this developer configure a different URL in appsettings.development.json without overwriting my settings when he checks it in?

like image 667
Jonathan Wood Avatar asked Oct 15 '25 21:10

Jonathan Wood


2 Answers

I assume you use a Code versioning control tool. I will assume you use git. If it's not the case, you SHOULD use a Versioning Control tool, if it's not git, check how you can "ignore" specific files.

You should not track the appSettings.development.json and add it to your .gitignore (see this thread if appSettings.development.json is already tracked and you need to clean it.)

Then each developer will have his own appSettings.development.json and it will not be overwritten

HTH

like image 59
Cyril ANDRE Avatar answered Oct 18 '25 10:10

Cyril ANDRE


You could use user secrets for this. It's basically a JSON config file that is outside the project folder so it won't get checked in to version control. I've used this for local DB connection strings/API URLs etc.

In Visual Studio you can right click the project and click Manage user secrets to open the user secrets file.

like image 27
juunas Avatar answered Oct 18 '25 10:10

juunas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!