views:

209

answers:

1

I'm trying to build an MSBuild custom task in IronPython using SharpDevelop 3.1 (IronPython 2.0.0).

In order to build a custom task, the class needs to implement the Microsoft.Build.Framework.ITask interface. According to this post you can implement a .NET interface by inheriting from it.

The ITask interface defines two properties, BuildEngine and HostObject, as well as an Execute method. The execute method takes no arguments and returns a boolean.

I've written the following code with the appropriate references in the solution:

import Microsoft.Build.Framework as mbf
import Microsoft.Build.Utilities as mbu

class CustomTask(mbf.ITask):
    '''
    Print a message to the log.
    '''
    def __init__(self):
        self.BuildEngine    =   None
        self.HostObject     =   None

    def Execute():
        log     =   mbu.TaskLoggingHelper(self)
        log.LogMessageFromText('This is a test.', mbu.MessageImportance.High)
        return True

The code builds without error. When I use MSBuild Sidekick to attempt to make an MSBuild file that uses the "UsingTask" element to reference the resulting dll, it complains that the dll does not contain any tasks.

I'm guessing the issue is either with an incomplete interface implementation on my part (most likely the properties, since I'm faking them with attributes) or a version issue (IronPython 2.0 versus 2.1 in the post). Any experience or advice to be offered?

A: 

I expect you didn't make the class public.

drbillll