The link to the Boolean custom function helped.

 

My first problem was that “using NAnt.Core.Types” was not in the examples I’d seen so far, and that’s where Function and FunctionSet are picked up from.

 

My second problem was that when I copied my .dll to the nant bin directory and tried to call my function from a build file I got:

 

Unknown function <myfunction>

 

I had to use <loadtasks … /> to load my custom function definition. Is this a bug?

 

I’m executing the function now, so things are much better.

 

Thanks,

 

Jody

 


From: Gert Driesen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 07, 2006 12:33 AM
To: Jody Williams; [email protected]
Subject: Re: [NAnt-users] C# custom function

 

Hi Jody,

 

I'm not sure where you found that information, but Function and FunctionSet have not been replaced.

 

For an example, you can always check out the custom functions that are part of the NAnt distibution.

 

 

Here's an example of an inline function that checks whether a given assembly is deployed in BizTalk:

 

<script language="C#" prefix="biztalk">
    <references basedir="${path::combine(bts.install.dir, 'Developer Tools')}">
        <include name="Microsoft.BizTalk.ExplorerOM.dll" />
    </references>
    <imports>
        <import namespace="Microsoft.BizTalk.ExplorerOM" />
    </imports>
    <code>
        <![CDATA[
            [Function("is-assembly-deployed")]
            public bool IsAssemblyDeployed(string server, string mgmtDb, string assemblyName) {
                BtsCatalogExplorer ce = new BtsCatalogExplorer();
                ce.ConnectionString = "Integrated Security=SSPI;" +
                    "database=" + mgmtDb + ";server=" + server;
                return (ce.Assemblies[assemblyName] != null);
            }
        ]]>
    </code>
</script>
<echo message="Deployed: ${biztalk::is-assembly-deployed('myServer', 'myDb', 'AnAssemblyName')}" />

 

Hope this helps,

 

Gert

 

 

----- Original Message -----

From: "Jody Williams" <[EMAIL PROTECTED]>

Sent: Tuesday, March 07, 2006 3:08 AM

Subject: [NAnt-users] C# custom function

 

I've just started using NAnt, and the documentation I've found on
writing custom functions seems to be out of date. It looks like
FunctionSet and Function have been replaced. I thought I found the
correct replacements, but when I try to copy my .dll to the nant
directory and call the function from a build file, I get the message
"property <my function set> has not been set".

 

Does anyone have a C#  example that works with nant-0.85-rc3 they could
share? If there are any other instructions for making the custom
function available to build files, I'd appreciate those, too.

 

Thanks,

 

Jody

Reply via email to