муравей не выполняет .exe файл - PullRequest
0 голосов
/ 12 мая 2011

мой 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 голосов
/ 12 мая 2011

Две вещи в вашем скрипте выглядят странно.

  1. Не думаю, что вам нужно задание <sequential> в цели <main>.
  2. Атрибут dependsВаша цель <main> приведет к выполнению цели <init> до Searchversion.exe.Так что, возможно, он запускается, просто слишком поздно.

Предполагая, что # 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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...