private string TryCreatePersistedTransformAssembly(string commandLine, bool createFromInputFile, bool expectedToSucceed, string targetDirectory)
{
// If createFromInputFile is specified, create an input file now that the compiler can consume.
string processArguments = createFromInputFile ? "@" + CreateInputFile(commandLine) : commandLine;
var processStartInfo = new ProcessStartInfo
{
FileName = XsltVerificationLibrary.SearchPath("xsltc.exe"),
Arguments = processArguments,
//WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
WorkingDirectory = targetDirectory
};
// Call xsltc to create persistant assembly.
var compilerProcess = new Process
{
StartInfo = processStartInfo
};
compilerProcess.Start();
string output = compilerProcess.StandardOutput.ReadToEnd();
compilerProcess.WaitForExit();
if (createFromInputFile)
{
SafeDeleteFile(processArguments.Substring(1));
}
if (expectedToSucceed)
{
// The Assembly was created successfully
if (compilerProcess.ExitCode == 0)
{
return output;
}
throw new CTestFailedException("Failed to create assembly: " + output);
}
return output;
}