vbc vommand line compiler verbose messages

Discussion in 'ASP .Net' started by Sam, Nov 11, 2003.

  1. Sam

    Sam Guest

    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.
    Sam, Nov 11, 2003
    #1
    1. Advertising

  2. Sam

    Natty Gur Guest

    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


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, Nov 11, 2003
    #2
    1. Advertising

  3. Sam

    Todd Acheson Guest

    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.



    "Sam" <> wrote in message
    news:...
    > 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.
    Todd Acheson, Dec 2, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. neo

    vbc.exe

    neo, Dec 5, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,053
    Guinness Mann
    Dec 11, 2003
  2. Dave Willock
    Replies:
    1
    Views:
    3,966
    John Timney \(Microsoft MVP\)
    Jan 10, 2004
  3. guyzdancin
    Replies:
    0
    Views:
    571
    guyzdancin
    Jan 11, 2006
  4. guyzdancin
    Replies:
    2
    Views:
    534
    Andrea Desole
    Jan 13, 2006
  5. Mark Carrington

    vbc compiler error code 1

    Mark Carrington, Feb 22, 2007, in forum: ASP .Net
    Replies:
    7
    Views:
    550
    Steven Cheng[MSFT]
    Mar 6, 2007
Loading...

Share This Page