How to get the output from devenv

  • Thread starter Thread starter MarvelousSoftware
  • Start date Start date
M

MarvelousSoftware

Guest
I have a large bat file that compiles my projects. After it is done I have to scroll through a text file to check for errors. I would like to automate this. The problem I am having is when I run devenv from process start I can not get the output. Other programs give me output, but not devenv. Can someone tell me what I am doing wrong?

I have over 100 lines like this:


"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv" "Rotair_IMSExtensions\Rotair_IMSExtensions.sln" /build >> ..\Output\Build.txt
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv" "Rotair_GeneralFunctions\Rotair_GeneralFunctions.sln" /build >> ..\Output\Build.txt
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv" "Rotair_Objects\Rotair_Objects.sln" /build >> ..\Output\Build.txt

...




So I tried this:

Dim strError As String
Dim strOutput As String
Dim Process As Process
Dim StartInfo As ProcessStartInfo


Process = New Process
StartInfo = New ProcessStartInfo

StartInfo.FileName = "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv"
StartInfo.Arguments = String.Format("""" & Directory.GetCurrentDirectory & "\{0}"" /BUILD ""Release|Any CPU""", strFile)
StartInfo.UseShellExecute = False
StartInfo.RedirectStandardOutput = True
StartInfo.RedirectStandardError = True
StartInfo.CreateNoWindow = True
Process.StartInfo = StartInfo


Process.Start()
strOutput = Process.StandardOutput.ReadToEnd
strError = Process.StandardError.ReadToEnd
Process.WaitForExit()

For Each strOutlineLine In strOutput.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
If strOutlineLine <> String.Empty Then
UpdateGrid("COM", strOutlineLine, "True")
End If
Next

For Each strOutlineLine In strError.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
If strOutlineLine <> String.Empty Then
UpdateGrid("ERR", strOutlineLine, "False")
End If
Next


If I replace devenv with a console application it works. I get results and errors. Denenv does compile my project, but I get no output. I cant tell if it fails or succeeds.

I also tried this:

Public Sub Compile_OutputDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)

mstrOutput.Add(e.Data)

End Sub

Public Sub Compile_ErrorDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)

mstrError.Add(e.Data)

End Sub


Private Sub Compile1(strFile As String)

Dim Process As Process
Dim StartInfo As ProcessStartInfo


Process = New Process
StartInfo = New ProcessStartInfo

StartInfo.FileName = "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv"
StartInfo.Arguments = String.Format("""" & Directory.GetCurrentDirectory & "\{0}"" /BUILD ""Release|Any CPU""", strFile)
StartInfo.UseShellExecute = False
StartInfo.RedirectStandardOutput = True
StartInfo.RedirectStandardError = True
StartInfo.CreateNoWindow = True
Process.StartInfo = StartInfo

AddHandler Process.OutputDataReceived, AddressOf Compile_OutputDataReceived
AddHandler Process.ErrorDataReceived, AddressOf Compile_ErrorDataReceived


Process.Start()
Process.BeginErrorReadLine()
Process.BeginOutputReadLine()
Process.WaitForExit()


For Each strOutlineLine In mstrOutput
If strOutlineLine <> String.Empty Then
UpdateGrid("COM", strOutlineLine, "True")
End If
Next

For Each strOutlineLine In mstrError
If strOutlineLine <> String.Empty Then
UpdateGrid("ERR", strOutlineLine, "False")
End If
Next

End Sub

Again, I get output from a console application, but nothing from devenv.


Can someone please assist me?

Continue reading...
 
Back
Top