Managing connection strings in source controlled application that is continuously deployed to Azure websites

前端 未结 2 535
天涯浪人
天涯浪人 2021-01-12 19:55

Here\'s the scenario: I have multiple developers on an asp.net mvc 4 project. Each developer has a local database. The source control system is TFS at http://tfs.visualst

2条回答
  •  鱼传尺愫
    2021-01-12 20:08

    Slow Cheetah is actually a nice solution. It's an extension to web.config transformations. Those transformations let you keep one web.config file and then for each deployment scenario you specify which changes you want to it. For example, your Release configuration will probably remove the debug attribute.

    This can also be used to change connection strings. The transformations are applied during the deployment of your project to Azure.

    What I've done in the past to make this also work with local development machines is use a web.config with an externalized connections.config file. Each developer created a connection.machinename.config file that was copied to connection.config on build in the post-build step. Those files don't have to be checked in and they can never cause conflicts because each machine name is unique.

    The release/staging/.. configurations used a web.config transformation to replace the connection string element with a specific connection string for that deployment (and that way remove the dependency on the external config file).

    Slow Cheetah offers some nice helpers for checking the result of these transformations at design time.

提交回复
热议问题