C # - How to determine if a source compiled successfully

I am running the C # compiler in code like my own IDE.

I am creating a batch file for the command line.

And run Process.Start()

and wait until it HasExited

is true

.

But how do you know if the source compiled successfully?

Malcolm

+1


source to share


2 answers


Usually with command line applications, you can look at the return code (ERRORLEVEL in batch files). 0 means success. Everything else means some kind of failure.



+2


source


Why are you using csc through the process API instead of using the System.CodeDom.Compiler API? This will give you the same effect (in fact, it calls csc internally), but is cross platform, handles errors, allows you to more easily tweak options programmatically, etc.



+5


source







All Articles