作为 C# 进程启动时 makefile 配方失败

makefile recipe failed when started as a C# process

我有一个 makefile,当我在 windows 控制台 (cmd) 上 运行 这个 makefile 时,它​​完美地完成了所有的食谱。

但是,当我 运行 如下所示在 .NET 进程上运行此脚本时,它在某个部分失败了:

     Process featureExtractionProcess = new Process();

     featureExtractionProcess.StartInfo.FileName = "make.exe";

     featureExtractionProcess.StartInfo.Arguments = "all";
     featureExtractionProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
     featureExtractionProcess.StartInfo.UseShellExecute = false;
     featureExtractionProcess.StartInfo.WorkingDirectory = _runLocation;
     featureExtractionProcess.StartInfo.RedirectStandardOutput = true;
     Logger.Debug("Starting feature extraction in " + _runLocation);
     featureExtractionProcess.Start();
     StreamReader sr = featureExtractionProcess.StandardOutput;
     string output = sr.ReadToEnd();

常量误差为:

"Makefile:275: recipe for target 'list' failed"

食谱"list"是这样的:

list:

    mkdir -p lists
    rm -f tmp
    for spkr in $(TRAINSPKR); do \
        for lab in labels/full/$${spkr}/*.lab; do \
            if [ -s $${lab} -a -s labels/mono/$${spkr}/`basename $${lab}` -a -s cmp/$${spkr}/`basename $${lab} .lab`.cmp ]; then \
                sed -e "s/.* //g" $${lab} >> tmp; \
            fi; \
        done; \
    done
    sort -u tmp > lists/full.list
    rm -f tmp

make在循环后结束,不执行排序。

为什么 cmd 和 C# 进程在行为上存在差异?

感谢 Tsyvarev,我找到了解决方案。除了标准输出之外,我还重定向了标准错误:

featureExtractionProcess.StartInfo.RedirectStandardError = true;

并使脚本在 C# 进程中完成,没有任何问题