XdtTransformationAlias.

XdtTransformConfig(ICakeContext, FilePath, FilePath, XdtTransformationSettings) Method

Summary

Transforms configuration files using XDT Transform library.

Syntax

public static void XdtTransformConfig(this ICakeContext context, FilePath sourceFile, FilePath transformFile, XdtTransformationSettings settings)

Examples

 var target = Argument("target", "Default");

 Task("TransformConfig")
   .Does(() => {
 
     var sourceFile = File("web.config");
     var transformFile = File("web.release.config");
     var settings = new XdtTransformationSettings().UseDefaultLogger();

     XdtTransformConfig(sourceFile, transformFile, settings);
     
     if(settings.Logger.HasWarning)
     {
         var warnings = settings.Logger.Log
                           .Where(entry => entry.MessageType == XdtTransformationLog.Warning)
                           .Select(entry => entry.ToString());
                           
         var concatWarnings = string.Join("\r\n", warnings);
         
         throw new Exception("Transformation has warnings:\r\n" + concatWarnings);
     }
 });

 RunTarget(target);

Attributes

Type Description
CakeMethodAliasAttribute

Parameters

Name Type Description
context ICakeContext The context.
sourceFile FilePath Source file to be transformed. This is also the target file, indicating an in-place transform.
transformFile FilePath The transformation to apply.
settings XdtTransformationSettings The settings to use during transformation.

Return Value

Type Description
void