none
How to get the output from devenv RRS feed

  • Question

  • 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?

    Friday, August 9, 2019 6:28 PM

All replies

  • Let's look at the Devenv command line switches. I see an -Out switch. It is also shown with the -Build switch. Does that help?


    Sam Hobbs
    SimpleSamples.Info

    Friday, August 9, 2019 8:17 PM
  • Hi,

    get the output  after devenv processing

      Dim reader As StreamReader = Process.StandardOutput
            Dim curLine As String = reader.ReadLine()
            Using sr As StreamWriter = New StreamWriter("Filepath", FileMode.OpenOrCreate)
                While Not reader.EndOfStream
    
                    If Not String.IsNullOrEmpty(curLine) Then
                        sr.WriteLine(curLine)
                    End If
    
                    curLine = reader.ReadLine()
                End While
            End Using

    Best Regards,

    Alex



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 12, 2019 8:32 AM
  • Hello,

    You might consider using the following open source viewer.

    https://github.com/KirillOsenkov/MSBuildStructuredLog


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, August 12, 2019 11:15 AM
    Moderator