【发布时间】:2011-01-12 21:49:40
【问题描述】:
我正试图决定在 MsBuild 与 Nant 战争中我站在哪一边。我开始:停止服务,部署一些文件,重新启动服务。只需查看这两个链接,在 Nant 中就更容易做到这一点。
MSBuild:Example of using Service Exists MSBuild task in Microsoft.Sdc.Tasks?
<target name="service_exists">
<script language="C#">
<references>
<include name="System.ServiceProcess.dll" />
</references>
<code><![CDATA[
public static void ScriptMain(Project project) {
String serviceName = project.Properties["service.name"];
project.Properties["service.exists"] = "false";
project.Properties["service.running"] = "false";
System.ServiceProcess.ServiceController[] scServices;
scServices = System.ServiceProcess.ServiceController.GetServices();
foreach (System.ServiceProcess.ServiceController scTemp in scServices)
{
etc...
南特:http://ryepup.unwashedmeme.com/blog/2007/01/04/restart-a-windows-service-remotely/
<!-- Send the stop request -->
<exec program="sc.exe">
<arg line="\\server stop shibd_Default"/>
</exec>
<!-- Sleep a little bit, to give the service a chance to stop -->
<sleep seconds="5"/>
<!-- Send the start request -->
<exec program="sc.exe">
<arg line="\\server start shibd_Default"/>
</exec>
我想知道 SO 社区是否同意我的观点。在 Nant 中完成类似这样的基本工作是否容易得多?当然看起来是这样的。 CDATA 块中的 C# 代码?怎么回事?
我们当前的构建过程是 a) 大量 bat 文件 b) 大量诅咒。我真的很想找到一个好的替代品,但是 MsBuild 的东西在我看来就像一个痛苦的世界。我认为要走的路是在 Nant 中构建脚本,然后使用 MsBuild 进行任何需要完成的 .NET 构建。
一个重要问题:在脚本运行之前,哪一个更擅长捕捉脚本中的错误?我正在考虑在这里推出自己的产品,这是其中非常重要的一部分:排列所有数据并确保在尝试运行之前它是有意义的。
【问题讨论】:
标签: msbuild build-process nant