Search code examples
tfstfsbuildrelease-managementms-release-management

Process tokens in TfvcRelease12 build template 2013.4


How do I process tokens in the TfvcRelease 12 build template for TFS and Release Management 2013.4? I have both web.config and web.config.tokens files. I've seen this way:

http://www.colinsalmcorner.com/post/webdeploy-and-release-management--the-proper-way

But it also looks like this can be a solution:

/p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false

Solution

  • Turn the "Process tokens" flag to true in the release section of the build process template and make sure the web.config.token file is set to "Copy Always" in the application's project file.

    Another option that I've had some success with is to define a web.config transform for, say, the Release build configuration. In the transform, replace the baseline values in the web.config with the tokens. Then, open up the project file and add this snippet:

    <Target Name="AfterBuild">
        <TransformXml Condition="Exists('$(OutDir)\_PublishedWebsites\$(TargetName)')"
                      Source="Web.config"
                      Transform="$(ProjectConfigTransformFileName)"
                      Destination="$(OutDir)\_PublishedWebsites\$(TargetName)\Web.config" />
    </Target>
    

    [Source]

    That snippet will force the config transform to run, but only if it's building on a TFS build server. It works wonderfully.

    Note: All this will do is copy the web.config.token file over the web.config file during the build process. It's up to you to then define the tokens within your component in RM, and then provide values in your release template.