蚂蚁不执行.exe文件 [英] ant not executing .exe file

查看:17
本文介绍了蚂蚁不执行.exe文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

my searchversion.exe file is not running in the script..why is that so?

<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 will generate latestbuild.properties file. I do not have any arguments for 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)

sslist.exe gets a list of snapshots found in my version control software, and i will get the greatest version number and save it as a text (latestbuild.properties)

推荐答案

脚本中有两处看起来很奇怪.

Two things in your script look odd.

  1. 我认为您不需要 目标中的
    任务.
  2. 目标的 depends 属性将导致 目标在 Searchversion 之前运行.exe.所以,也许它正在运行,但为时已晚.
  1. I don't think you need the <sequential> task in the <main> target.
  2. The depends attribute of you <main> target will cause the <init> target to run before Searchversion.exe. So, perhaps it is getting run, just too late.

假设 #2 是您的问题的原因,您应该将脚本重构为如下所示:

Assuming #2 is the cause of your problem you should restructure your script to look like this:

<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>

这篇关于蚂蚁不执行.exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆