Skip to content
Sergey Zwezdin edited this page Jun 18, 2016 · 3 revisions

Cake (C# Make) is a cross platform build automation system with a C# DSL. Magic Chunks have integrated Cake aliases to use it inside your Cake scripts.

Steps to setup config transformations at Cake scripts:

Step 1: Add Magic Chunks reference at the top of the script:

#addin "MagicChunks"

Once you do this Cake will download Magic Chunks library from Nuget during your build.

Step 2: Add TransformConfig alias call at your Cake script:

Task("Default")
    .Does(() => {

        TransformConfig(@"Web.config", "Web.transformed.1.config",
          new TransformationCollection {
            { "configuration/system.web/authentication/@mode", "Forms" },
            { "configuration/system.web/httpRuntime", "125" }
          });

    });

TransformConfig alias

There are few overloads for TransformConfig alias:

  • bool TransformConfig(path, transformations)
  • bool TransformConfig(path, target, transformations)
  • bool TransformConfig(type, path, target, transformations)

TransformConfig alias parameters:

  • path − path to source file.
  • target − path to target file (default value: same as path parameter).
  • type − type of document: Xml, Json, Yaml and so on (default value: auto - library will detect document type automatically).
  • transformations − key-valued collection of transformations.

You can find complete sample cake script here.