Is there a way to access the Project object from a NAnt extension function, as can be done from an extension task?
In this example, I want to use the BaseDirectory property inside the Bar function:
[FunctionSet('foo', 'Foo')] public class FooFunctions : FunctionSetBase { public FooFunctions(Project project, PropertyDictionary properties) : base(project, properties) { // When does this constructor gets called? } [Function('bar')] public static string Bar(string name) { return 'Bar!'; // How to get at project.BaseDirectory? } }
I’m new to NAnt extensions, so I don’t know if this is even a valid question or if I should approach the problem differently.
Great question Tom. The abstract base class, FunctionSetBase, has a property called Project that you can access from the Bar function. However, I noticed that the Bar function is declared static, which is not always necessary (but not wrong).
The following should be completely legal in NAnt world:
Are you seeing any problems?