Question

This question is kind-of two in one, but both are related to the same problem.

We are a team of 10 developers, some developers prefer to use a full instance of IIS, while others prefer to use IIS-Express. There are merits to using either, for example, IIS most closely resembles production, while IIS-Express allows Edit-and-Continue debugging.

In addition to the 10 developer work team, we are using source control, and we have a branching structure. Each branch may have different web.config / app.config settings, such as database connection strings. A developer may be working on more than one branch a time, so we typically have one database per branch, we are looking at developers having local databases, but the naming collision is still a problem regardless of the approach (i.e. a developer may have 2 local databases, one for each branch).

The first issue, is the one with the csproj files, specifically the web-server settings. If one developer checks in a csproj file that uses IIS-Express, and the other developer does a Get Latest, it will overwrite their configuration, wasting time and creating frustration.

Of course, the easiest solution would be to force everyone to use one tool, one configuration, but I would rather not do that, especially for something that has no bearing on the resulting output (compiled code).

The second issue is with the config files, the config files are stored in source control (just like any other file), so when we do branching-merging, these files have to be updated manually afterwards. I know that there are the Debug and Release transformations for config files, which we could have different connection strings in both, but this does not solve the issue for two individual developers may be working on the same branch but with different connection strings.

The obvious solution to this is everyone has the exact same settings always, but some developers may want to use LocalDB instance, others may want to use SQL-Express, while the staging server uses a full-on SQLServer Instance. Again, this is another setting that has no bearing one the final result.

I have not seen any solutions to my particular problems, in regards to managing configurations between team members, and between branching/merging.

Was it helpful?

Solution

Specifically for web server, VS has a checkbox of "Apply server settings to all users (store in project file)" - if unchecked, then the setting is stored in your local .csproj.user file, so everyone can have their own settings there.

For connection strings, you can have a "user.config" file on each machine (not in source control), where the developer can put their connection string in. The main config file can just load this file up to get the connection string. There are a few ways of doing this, but I've tried this:

App.config or Web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings configSource="user.config"></connectionStrings>
</configuration>

user.config:
<connectionStrings>
  <add name="test" connectionString="Server=.;Database=...;"/>
</connectionStrings>

If it was a Windows app, you'd set the "Copy to Output Directory" property on the user.config file, so that Visual Studio would copy it to your bin directory.

OTHER TIPS

If I understand your question correctly, you would basically like to exclude your app.config / web.config / certain other files from being checked in? For some reason, this seems to be somewhat of a hidden option...

We finally found the answer to our similar problem by selecting the .config files in the Solution Explorer, and clicking on (Visual Studio) File -> Source Control -> Exclude selection from Source Control.

This will keep the selected files from being checked in and overwriting the other developer's files.

(Note: this works in VS2010, I can't make any guarantee that this option exists in 2012)

I have had a similar problem where I have had 3 databases for 3 branches for 3 environments.

Production Server ==> Production DB ==> prod branch ==> Prod connection string Testing Server ==> Master DB ==> Master branch ==> master connection string local Development ==> local DB ==> developer branch ==> developer connection string ...

Inside of .git folder, there are git hooks where you can put scripts to execute whenever you checkout a branch. I have post-checkout script which executes itself every time I checkout and that updates connection string for me so that saves me from manual changes to the web.config file :

!/bin/bash

. config eval $(git branch | grep "" | sed "s/ //")

sed -e s/{SERVER}/$server/g -e s/{DATABASE}/$database/g -e s/{USER}/$user/g -e s/{PASS}/$pass/g -e s/{SITE_TYPE}/$site_type/g \

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top