MSBuildTaskAliases.

MSBuildTaskExecute(ICakeContext, ITask) Method

Summary

Executes an MSBuild task
Assembly
Cake.MSBuildTask.dll
Namespace
Cake.MSBuildTask
Containing Type
MSBuildTaskAliases

Syntax

public static void MSBuildTaskExecute(this ICakeContext context, ITask task)

Examples

This sample shows how to call the Cake.MSBuildTask.MSBuildTaskAliases.MSBuildTaskExecute(Cake.Core.ICakeContext,Microsoft.Build.Framework.ITask) extension.
// 1. Add reference to addin the top of your cake script:
#addin Cake.MSBuildTask

// 2. Reference the dll(s) that has the MSBuild task(s) you want to use in your build
// Note that for MSBuild.Extension.Pack the present version of Cake (0.5.4) can't use
// '#addin MSBuild.Extension.Pack' as the Nuget package has two versions of dlls in it
// instead you need to add MSBuild.Extension.Pack to tools/packages.config and reference dll like so:
#r .\tools\Addins\MSBuild.Extension.Pack\tools\net40\MSBuild.ExtensionPack.dll

// 3. Use the MSBuild task in the script.
// Here we are using SVN task from  MSBuild.Extension.Pack:
Task("TestMSBuildTask")
    .Does(() =>
    {
        // a. Create the task
        var svn = new MSBuild.ExtensionPack.Subversion.Svn();
        var checkoutFolder = GetDirectories("./SrcFolder").FirstOrDefault();

         // b. Configure the task
        // If the folder doesn't exist then do a Checkout, otherwise Update.
        if (checkoutFolder == null)
        {
            checkoutFolder = MakeAbsolute((DirectoryPath)"./SrcFolder");
            svn.TaskAction = "Checkout";
            // The .ToTaskItem() and .ToTaskItems() are helper methods provided by MSBuildTaskAliases
            svn.Items = checkoutUrl.ToTaskItems();
            svn.Destination = checkoutFolder.ToTaskItem();
        }
        else
        {
            svn.TaskAction = "Update";
            svn.Items = checkoutFolder.ToTaskItems();
        }
 
        // c. Execute the task
        MSBuildTaskExecute(svn);
    });

Attributes

Type Description
CakeMethodAliasAttribute

Parameters

Name Type Description
context ICakeContext Cake context
task ITask The task.

Return Value

Type Description
void