XdtTransformationAlias.

XdtTransformConfigWithDefaultLogger(ICakeContext, FilePath, FilePath, FilePath) Method

Summary

Transforms configuration files using XDT Transform library and returns transformation log

Syntax

public static XdtTransformationLog XdtTransformConfigWithDefaultLogger(this ICakeContext context, FilePath sourceFile, FilePath transformFile, FilePath targetFile)

Examples

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

 Task("TransformConfig")
   .Does(() => {
 
     var sourceFile = File("web.config");
     var transformFile = File("web.release.config");
     var targetFile = File("web.target.config");
     var log = XdtTransformConfigWithDefaultLogger(sourceFile, transformFile, targetFile);
     
     if(log.HasWarning)
     {
         var warnings = log.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.
transformFile FilePath Transformation file.
targetFile FilePath Output file name for the transformed file.

Return Value

Type Description
XdtTransformationLog