I have a makefile and when I run this makefile on a windows console (cmd), it perfectly completes all the recipes.
However, when i run this script on a .NET process as shown below, it fails on a certain part:
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();
The constant error is:
"Makefile:275: recipe for target 'list' failed"
the recipe "list" is like this:
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
The make ends just after the loop and does not execute sort.
Why is there a difference in behavior between cmd and C# process?
sedcommand is failed for some reason. Probably, error message for that fails is written tostderr, but you redirect onlystdoutin your C# code. I am unsure, but difference between running make fromcmdand C# (as a process) could be using different shells, which interprets make receipts. Or different environment for the shell (such as environment variables). - Tsyvarev