Should I ignore the launchSettings.json file from being committed in Git?
Solution 1
launchSettings.json
should not be ignored. That repository has since been updated to not ignore it: https://github.com/github/gitignore/pull/2705
Reasons for making this change:
Ignoring
launchSettings.json
does not make much sense. Now .NET CLI even considers this file when running withdotnet run
, as you can read here.This settings will be useful if shared among project members, so it should be commited to the repo.
Links to documentation supporting these rule changes:
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-run?tabs=netcore2x
Solution 2
One reason that this might be done as a general practice is to keep secrets out of the repo.
If you're using environment variables to store DB passwords, API keys, and so on, you can configure those for your dev hosting environment under Project Properties -> Debug, as key-value pairs.
That configuration gets persisted locally in the project's launchSettings.json
, so by keeping that file out of commits you avoid leaking privileged information into your repo.
Note though, that the current best practice is not to store secrets in this way at all during development, but to use the Secrets Manager instead.
Solution 3
OK now I know why, I deleted that file, but the options of this project are still saved somewhere there, the options simply did not get lost after deleting this file. The file seems to be automatically generated when I do any new change to the project options, so my old version with the new changes is going to be there again.
I am not sure what is the benefit of it in this case, but at least I can say we can probably exclude it from the source control.
Please correct me if I missed anything.
Solution 4
It depends on the context of your project,
If you are going to share your source code with your colleagues or client and wanted to run the project with the same set of settings which you have used apart from default like "uriFormat"
which will redirect to a specific Url on application start.
This kind of settings will not be available to next user if it is going to run the code from your repository.
Related videos on Youtube
Mohammed Noureldin
Austrian software engineer with a focus not only on coding, but also on every single detail of software engineering, equipped with a diversity of promising and useful skills, like deep knowledge in different programming languages and frameworks, hands-on embedded systems, and a thorough DevOps experience. Always interested in the latest cutting-edge technologies, and recently started gaining deep knowledge and experience in the field of machine learning and artificial intelligence. My huge passion for technology motivated me to self-educate myself in these different technical fields, and the vision to the future keeps pulling me to develop myself continuously. Additionally, a pharmacist holds a doctoral degree (Ph.D.) in pharmacology from the University of Graz in Austria. Besides being a husband to a beautiful doctor, but not a father yet. To keep myself fit (though in the being time I am not really committed), swimming, table tennis, and cycling are my favorites. Occasionally I like to play some computer or board games. If You Are Working On Something That You Really Care About, You Don’t Have To Be Pushed. The Vision Pulls You. – Steve Jobs
Updated on July 13, 2022Comments
-
Mohammed Noureldin almost 2 years
I find this relatively known GitHub repository, where they considered
launchSettings.json
file (which is used by Visual Studio 2017 for .Net Core projects) is to be ignored.https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
Why should it be ignored? I used always in the company I work in to commit it, I am curious to know if there is any reason to ignore it.
-
kabal over 4 years
launchSettings.json
has actually been removed from this.gitignore
- github.com/github/gitignore/commit/… -
Ken TuckerI am guessing because it could be more user specific settings. For example you might use IIS to host the site while a coworkers uses IIS express
-
-
Mohammed Noureldin about 4 yearsThank you for the answer. May I ask you to give a bit more information about this file? For example what kind of information or settings will be shared in it? Just to make the answer includes everything necessary.
-
Bradley Grainger about 4 yearsMore documentation about the
launchSettings.json
file can be found here: docs.microsoft.com/en-us/aspnet/core/fundamentals/… Since the original question was about ignoring it in version control, I'd suggest asking a new question for more detailed information about the contents of this file, rather than increasing the scope of this existing question. -
mnj about 4 yearsIf
launchSettings.json
is supposed to be in git, how can we control Environment setting (Development, Production, etc.) if I have it set in this file to 'Development'? Especially in the context of CI/CD.