vbc vommand line compiler verbose messages

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

Does anyone know how I can call vbc.exe from a Windows Application and
return the output messages?

I thought I might be able to do it using the
System.Diagnostics.Process object. I have got it executing correctly
and I am able to perform builds using this object, however cannot get
feedback to my Windows Application by way of verbose messages to
verify the build was successful.

I have attempted to append a pipe style argument to the end of the
arguments I pass into the Process object, however they cause the
process to fail. I assume it is because vbc.exe does not recognise a
piped command as an argument for itself, even though the same
arguments used directly in a command window execute correctly.

I am thinking of the piped command to file argument to allow me to
monitor the file for changes and dynamically display it in my Windows
Application. If there is a better way that someone knows about then I
would love to hear about it.

<SampleCode>
Dim compile As System.Diagnostics.Process

' Create new Process object
compile = New System.Diagnostics.Process()
With compile
.StartInfo.FileName =
"C:\Windows\Microsoft.NET\Framework\v1.0.3705\vbc.exe"
.StartInfo.Arguments = "/out:bin/MyDll.dll /t:library /verbose
Test.vb > c:\VerboseOutput.txt"
.Start()
.Close()
End With
</SampleCode>

Thoughts? Comments?

Thanks,

Sam.
 
Hi,

1) you can use WaitForExit and ExitCode to get indication.
2) RedirectStandardOutput and StandardOutput.ReadToEnd should return the
string (I never tried them!)

sample code :

private bool StartAppWithArguments(string args,string FileName)
{
try
{

System.Diagnostics.Process myproc;
myproc = new System.Diagnostics.Process();

myproc.StartInfo.FileName = FileName;
myproc.StartInfo.Arguments = args;
//myproc.StartInfo.RedirectStandardOutput = true;
myproc.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Hidden ;
myproc.EnableRaisingEvents = true;



myproc.Start();
myproc.WaitForExit();
if( myproc.ExitCode == 0)
{
//string strRes = myproc.StandardOutput.ReadToEnd () ;
return true;
}
return false;
}
catch(Exception Err)
{
}

}

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
You can redirect the compiler output to a text file:

Example; output to FileName.txt:
vbc.exe (all your switches, etc) >>FileName.txt

Include the ">>" in your statement

Another Example:
vbc.exe /t:library /out:C:\MyPath\MyAssembly.dll
/reference:System.dll,System.Data.dll MyAssemblyCode.vb >>CompilerOutput.txt

I would probably create a BAT file and launch it with CMD.EXE, making sure
that the reference to vbc.exe is in my PATH variable. I do this all the
time when i build new releases of our software.
Using the System.Diagnostics.Process like you indicated is good. If you
want the window to be hidden, add to your WITH statement:
..StartInfo.WindowStyle = ProcessWindowStyle.Hidden

Good luck,

Todd A.
 
Back
Top