简体   繁体   English

如何从C#程序使用NAnt

[英]How to use NAnt from C# program

Looks like all NAnt classes are internal and there's no a public managed API exposed from NAnt. 看起来所有NAnt类都是内部的,并且没有从NAnt公开的公共托管API。 Is there a way I can call NAnt from C# program with a custom script and parameters? 有没有一种方法可以使用自定义脚本和参数从C#程序调用NAnt? Is there any 3rd party wrappers available somewhere? 某个地方有第三方包装吗? For now I'm considering two options: spawning a process and modifying NAnt manifest to add InternalsVisibleTo. 目前,我正在考虑两个选项:生成一个进程和修改NAnt清单以添加InternalsVisibleTo。

Referencing this . 引用 You can do the following. 您可以执行以下操作。

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "NAnt.exe";
startInfo.Arguments = "-buildfile:NantScript.build";
process.StartInfo = startInfo;
process.Start();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM