Semi-editable Files (eg config files) and version control - best practices?

后端 未结 8 2247
深忆病人
深忆病人 2020-12-30 17:17

So, I killed the build today by checking in a config file. It knows where the server is (think SQL server or the like), and I\'ve been working against the server which runs

8条回答
  •  生来不讨喜
    2020-12-30 17:49

    I think the accepted answer is good, but depending on your requirements, it may have limitations.

    We use the following approach. Note that we are .NET shop using VS and make use of MSBuild (inbuilt, community and custom) tasks.

    • App.config is ignored by version control but included in the project.
    • App.default.config is under version control and also included in the project. Instead of hard-coding things that can change, e.g. db connection strings, we use tokens instead.

    A project's BeforeBuild task looks for existance of App.config and if not found copies App.default.config to App.config. Also, the build server always deletes App.config if it exists on a CI build (ensures clean config). We also then use the MSBuild Community FileUpdate task to replace the tokens with the appropriate values based on whatever is building the project.

    For example, a fresh developer checkout can setup db connection strings for a local database, a nightly build can setup for the nightly db, etc.

提交回复
热议问题