2

Our project uses custom xml config file, that is currently located under the project as .xml file, with Copy to output: always. Currently, it is present in the repository.

The problem is that every developer uses each own database (and each own configuration file), so ideally we need to have different configuration files, and we do not want to commit them to the external repository.

Sometimes the format of the configuration file is changed, and all of us need to update it. Also we have a build server that is configured to clean the folder before updating source from the repository and building it, so the default file (configured for build server) should be contained in the repository.

The problems is that sometimes a dev forget to check out it's local copy of the configuration xml when building, and his own config file goes to repository and brake many things. Is there any way to improve this schema so we don't need to remove config file from commit files every time we commit?

Archeg
  • 7,785
  • 5
  • 34
  • 81

3 Answers3

1

My solution is to exclude the app.config from VCS to prevent accidental commits to it. We have created an app.example.config which is checked in. A pre-build event validates if the app.config file exists and if it does not copies the .template to the .config file before compile of the codebase. This ensures the build server has a working config file which contains basic settings for all environments.

Example for PRe-build event in your project configuration:

REM copy .example files to .config files if needed
IF NOT EXIST "$(projectDir)\App.Config" IF EXIST "$(projectDir)\app.example.config" COPY "$(projectDir)\app.example.config" "$(projectDir)\App.Config"
IF NOT EXIST "$(projectDir)\Web.Config" IF EXIST "$(projectDir)\Web.example.config" COPY "$(projectDir)\Web.example.config" "$(projectDir)\Web.Config"
IF NOT EXIST "$(projectDir)\ConnectionStrings.Config" IF EXIST "$(projectDir)\ConnectionStrings.example.config" COPY "$(projectDir)\ConnectionStrings.example.config" "$(projectDir)\ConnectionStrings.Config"
IF NOT EXIST "$(projectDir)\Local.Config" IF EXIST "$(projectDir)\Local.example.config" COPY "$(projectDir)\Local.example.config" "$(projectDir)\Local.Config"
Mark van Straten
  • 8,503
  • 2
  • 34
  • 56
0
  1. Config in repo contain data for TeamCity
  2. Developers have MQ and patch in MQ-stack for converting default xml to local
  3. Changed base xml require to edit (rebase) patch and remove conflicts
Lazy Badger
  • 87,730
  • 7
  • 72
  • 97
0

Here's another answer similar to the accepted one by Mark, but using the <Copy> task in the .csproj file, which you were apparently looking for:

how to ignore files in kiln/mercurial using tortoise hg "that are part of the repository"

Community
  • 1
  • 1
Christian Specht
  • 33,837
  • 14
  • 123
  • 176