We have a bunch of appSettings
in our ASP.NET web application, not to mention connection strings, that change on a per-environment basis. Not just for different environments to which the web application is deployed, but across different developer machines too. Therefore, changing these with a Web.config
transform isn't good enough because these transforms aren't carried out when developers debug the application.
At the moment the settings are hard-coded into Web.config
but if a developer wants to change them during development, this obviously means the change is flagged up in source control which is undesirable. These changes shouldn't be checked into source control.
How can we move these settings out so that they can be changed without affecting source control? In the past I have worked on projects where we used configSource
to point to an external config file which was then excluded from source control, and a .config.example
file was put in its place which had to be copied to the .config
file. The trouble with this is that by default, it gives a broken build because this config file is missing until it's created. We want a working build that can be pushed to VSTS for deployment. How can we do this while keeping the per-environment settings separate from source control?