在 nant 构建脚本中调用 C# 代码 - 时间影响?

发布于 2024-08-24 00:47:26 字数 903 浏览 2 评论 0原文

我的 nant 构建脚本中有一段 C# 代码,它运行并使用我想要的任何消息更新控制台窗口的标题,这就是这个(并且运行得很好):

    <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> 

不过我的问题是,将从 nant 调用此 C# 代码任何负面时间都会影响整个构建脚本的总运行时间。

我尝试通过使用和不使用此 C# 代码运行它来亲自测试这一点,并且存在边际差异,但在我真正将其部署到我的脚本中并对构建时间产生巨大影响之前,我想要一个更正式的答案。内部开发的潜在庞大系统。

编辑:我更担心的是需要时间来解析/编译/执行 C# 代码。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

余生共白头 2024-08-31 00:47:26

当执行封闭任务(在本例中为“脚本”)时,NAnt 将编译此 C# 脚本一次。编译后,生成的任务 (TestTask) 是编译后的 CLR 代码,与任何其他程序集中的代码没有什么不同。

它通过 CodeDom 进行编译,GenerateInMemory=true。

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.

薯片软お妹 2024-08-31 00:47:26

该代码片段不包含 I/O,除非您的构建脚本每秒多次更改该图块,否则没有理由相信这甚至是可测量的。

The snippet contains no I/O and unless your buildscript is going to change that tile many times per second there is no reason to believe this is even going to measurable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文