2011-05-12 144 views
0

我的searchversion.exe文件沒有在腳本中運行..爲什麼?螞蟻沒有執行.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

回答

0

腳本中的兩件事情看起來很奇怪。

  1. 我不認爲你需要在<main>目標<sequential>任務。
  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> 
+0

感謝,它的工作對不起,我在我的代碼在前面有一個錯字 – jeremychan 2011-05-12 06:15:41