ant没有执行.exe文件

时间:2011-05-12 03:21:06

标签: ant

我的searchversion.exe文件没有在脚本中运行..为什么会这样?

<project name="nightly_build" default="main" basedir="checkout">
    <target name="init">
        <property file="initial.properties"/>
        <property file="C:/Work/lastestbuild.properties"/>
        <tstamp>
            <format property="suffix" pattern="yyyyMMddHHmmss"/>
        </tstamp>
    </target>
    <target name="main" depends="init">
        <sequential>
            <exec executable="C:/Work/Searchversion.exe"/>
                ...
        </sequential>
    </target>
</project>

Searchversion.exe将生成latestbuild.properties个文件。我没有任何关于Searchversion.exe的参数。

以下是searchversion.exe的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Search
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = "sslist.exe";
            p.StartInfo.Arguments = "-R -H -h sinsscm01.ds.net /mobile";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.Start();
            string procOutput = p.StandardOutput.ReadToEnd();
            string procError = p.StandardError.ReadToEnd();
            TextWriter outputlog = new StreamWriter("C:\\Work\\listofsnapshot.txt");
            outputlog.Write(procOutput);
            outputlog.Close();
            string greatestVersionNumber = "";
            using (StreamReader sr = new StreamReader("C:\\Work\\listofsnapshot.txt")) 
            {
                while (sr.Peek() >= 0) 
                {
                    var line = sr.ReadLine();
                    var versionNumber = line.Replace(@"6.70_Extensions/6.70.102/ANT_SASE_RELEASE_", "");
                    if(versionNumber.Length != line.Length)
                    greatestVersionNumber = versionNumber;
                }
            }
            Console.WriteLine(greatestVersionNumber);

            TextWriter latest = new StreamWriter("C:\\Work\\latestbuild.properties");
            latest.Write("Version_Number=" + greatestVersionNumber);
            latest.Close();
        }
    }
}

sslist.exe获取我的版本控制软件中找到的快照列表,我将获得最大版本号并将其另存为文本(latestbuild.properties

1 个答案:

答案 0 :(得分:0)

你的剧本中的两件事看起来很奇怪。

  1. 我认为您不需要<sequential>目标中的<main>任务。
  2. depends目标的<main>属性会导致<init>目标在Searchversion.exe之前运行。所以,也许它正在运行,为时已晚。
  3. 假设#2是导致问题的原因,您应该将脚本重构为如下所示:

    <project name="nightly_build" default="main" basedir="checkout">
        <target name="init">
            <exec executable="C:/Work/Searchversion.exe"/>
            <property file="initial.properties"/>
            <property file="C:/Work/lastestbuild.properties"/>
            <tstamp>
                <format property="suffix" pattern="yyyyMMddHHmmss"/>
            </tstamp>
        </target>
        <target name="main" depends="init">
            ...
        </target>
    </project>