I'm going to precompile an asp.net application in my custom c# form. How do i retrieve the process logs and check whether it is a successful process or not?
Here's my code
string msPath = "c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\";
string msCompiler = "aspnet_compiler.exe";
string fullCompilerPath = Path.Combine(msPath, msCompiler);
msPath.ThrowIfDirectoryMissing();
fullCompilerPath.ThrowIfFileIsMissing();
ProcessStartInfo process = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
WorkingDirectory = msPath,
FileName = msCompiler,
Arguments = "-p {0} -v / {1}"
.StrFormat(
CurrentSetting.CodeSource,
CurrentSetting.CompileTarget)
};
Process.Start(process);
Thanks!
Set your
ProcessStartInfo.RedirectStandardOutput
totrue
- this will redirect all output toProcess.StandardOutput
, which is a stream that you can read to find all output messages:You can also use the
OutputDataReceived
event in a similar way to what @Bharath K describes in his answer.There are similar properties/events for
StandardError
- you will need to setRedirectStandardError
totrue
as well.