m00nbeam360
m00nbeam360

Reputation: 1377

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

Upvotes: 1

Views: 335

Answers (2)

Graham Smith
Graham Smith

Reputation: 527

Both are valid but I prefer /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false since it's cleaner. I have a blog post here that gives the details of how to set this up. Another of my posts explains the process of actually replacing the tokens with values for the environment being deployed to in an agent-based scenario. I'll have a PowerShell version of this available sometime this week as part of my Continuous Delivery with VSO series.

Upvotes: 3

Daniel Mann
Daniel Mann

Reputation: 59016

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.

Upvotes: 3

Related Questions