XdtTransformationAlias.

XdtTransformConfig(ICakeContext, FilePath, FilePath, FilePath, XdtTransformationSettings) Method

Summary

Transforms configuration files using XDT Transform library.

Syntax

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

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 settings = new XdtTransformationSettings().UseDefaultLogger();

     XdtTransformConfig(sourceFile, transformFile, targetFile, 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.
transformFile FilePath The transformation to apply.
targetFile FilePath Output file name for the transformed file.
settings XdtTransformationSettings The settings to use during transformation.

Return Value

Type Description
void