Search code examples
tfsbuild

TFS Build: replace connection string for tests


I'm trying to use TFS Build to execute database tests as part of a CI pipeline (nUnit), and I can't see how to modify the connection string. Is it done via an extra build step, or a settings file, or perhaps a variation of the config file?


Solution

  • You need to ensure the app.config file can find its references files from build agent machine according the reference path which you configured in your project. And the connecting strings must works on build agent machine to access the SQL Server which you defined in connecting string. Detail ways and some articles as follow:

    • Create a PowerShell script/.exe that replace the connection string
    • Check-In the script/.exe into source control
    • Execute the PowerShell script/.exe during the build as a task in the build definition

    For vNext build please refer this tutorial: Edit a Connection String from a TFS vNext Build

    For XMAL build please refer this link: How to: Run Database Unit Tests from Team Foundation Build-Modify the Test Project