views:

187

answers:

1

I have a section of C# code within my nant build script that runs and updates the console window's title with any message that I want, which is this (and runs perfectly fine):

    <script language="C#" > 
    <code unless="${string::ends-with(build.script.debug, 'off')}"> 
        [TaskName("consoletask")] 
        public class TestTask : Task 
        { 
            private string title; 

            [TaskAttribute("title", Required=true)] 
            public string Title 
            { 
                get { return title; } 
                set { title = value; } 
            } 

            protected override void ExecuteTask() { 
                System.Console.Title = title; 
            } 
        } 
    </code> 
    </script> 

My question though is, will calling this C# code from nant have any negative time impacts on the total running time of the overall build script.

I have tried to test this myself by running it with and without this C# code and there's marginal difference, but I wanted a more official answer before I go and deploy this into my scripts for real and make a massive difference to the build times of a potentially huge systems developed in-house.

edit: My worry is more that there's time needed to parse/compile/execute the C# code.

+1  A: 

NAnt will compile this C# script exactly once when the enclosing task is executed, which in this case is "script". Once compiled, the resulting task (TestTask) is compiled CLR code, no different to that in any other assembly.

It compiles via CodeDom, with GenerateInMemory=true.

Lachlan Roche
Bingo - thanks!
Brett Rigby