Sort Visual Studio Build Log in Build Order Style

The Visual Studio 2008 Output window displays the Show Output From drop-down list, which allows you to view build events ordered by stream ( Build Order ). This is very useful when building large solutions on multi-core machines, as the log entries from them are out of sync.

Our organization has an automated build process where the solution is compiled in batch using something like:

devenv Solution.sln /USEENV /build Release /out buildlog.txt

      

Download Solution.sln

, run it in config Release

and enter the build build log into buildlog.txt

.

The problem is this: buildlog.txt

- This is a result similar to the output of "Build" and not "Order Order" and therefore rather difficult to read. Is there a command line filter or something else that will convert the output to Order Order format?

+2


source to share


4 answers


Use a simple filter, something like this:



static void Main(string[] args)
{
    var lines = new Dictionary<int, StringBuilder>();
    var line = Console.In.ReadLine();
    while (line != null)
    {
        int process = 0;
        var re = new Regex(@"^(?<process>\d+)\>.*$");
        if (re.IsMatch(line))
        {
            var match = re.Match(line);
            process = Convert.ToInt32(match.Groups["process"].Value);
        }

        if (!lines.ContainsKey(process))
        {
            lines[process] = new StringBuilder();
        }
        lines[process].AppendLine(line);

        line = Console.In.ReadLine();
    }

    foreach (var i in lines.Keys)
    {
        Console.Write(lines[i]);
    }
}

      

+1


source


I don't know if this will solve the formatting problem, but you can try using msbuild

instead devenv

with the command line, for example:

msbuild Solution.sln /p:Configuration=Release /logger:XMLLogger,C:\Loggers\MyLogger.dll;OutputAsHTML



For information on logging options, see the documentation for msbuild. You may find that this will give you a smarter result.

+1


source


I don't think Walter is responsible for the whole situation, because I saw a problem when creating projects in C # and VS prints the compilation results with any process ID! such as

1> ------ Start Build: Project: MyProj, Configuration: Debug Any Processor ------

Compilation complete - 1 error, 0 warnings

Note that I removed most of the other outputs, but imagine you are building many projects and the complete compilation line is not inserted right after the correct project, how would you find which project belongs to the compilation?

0


source


The SortBuildOutput utility can sort the build log. It is based on Walter snippet .

0


source







All Articles