views:

597

answers:

3

There is a "Show output from" dropdown list in Visual Studio 2008 "Output" window, which allows viewing build events ordered by thread (Build Order). This is very useful when building big solutions on multi-core machines, as the log entries from those come unsynchronized.

Our organization has the automated build process, where solution(s) are compiled in a batch mode, using something like:

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

This will load Solution.sln, buld it in Release configuration and output build log into buildlog.txt.

Problem is: buildlog.txt is an output resembling "Build" output, not "Build Order", and therefore, it is pretty hard to read. Is there a command-line filter or something, which would convert output to "Build Order" format?

+1  A: 

I don't know whether this will solve the formatting issue, but you could try using msbuild instead of devenv, with a command line such as:

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

See the documentation for msbuild for information on the logging options. You may find that this will give you the ability to have a more sensible output.

the_mandrill
I guess this method is a valid resolution, although I couldn't make msconfig to build solution when I ran it using following line: "MSBuild.exe Solution.sln /p:Configuration=Debug /p:PlatformName=Win32 ", but once that's fixed, I guess, I could write custom logger to log properly. I would still like to see if there is a simpler resolution
galets
Try: `msbuild Solution.sln /p:Configuration="Release|Win32" /target:"MainProject"`
the_mandrill
Didn't work, but `MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform=Win32` did. Correct me if I am wrong, but doesn't MSBuild only build one project at a time? If yes, how will that help me with parallel builds?
galets
I think msbuild may build in parallel. Visual Studio itself uses msbuild under the hood, if I recall correctly.
the_mandrill
I ran msbuild it was only building one project at a time. I think Visual Studio spawns multiple MSBuilds
galets
I think that may be correct -- maybe it's in VS2010 where msbuild is able to parallelise.
the_mandrill
+1  A: 

Use simple filter, something like that:

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]);
    }
}
Walter
A: 

I don't think Walter's answer works for all the situation, because I've seen the problem when building C# projects and VS prints the Compile results withouth any process ID! such as

1>------ Build started: Project: MyProj, Configuration: Debug Any CPU ------

Compile complete -- 1 errors, 0 warnings

Please note that I removed most of other outputs but imagine you're building a lot of projects and Compile complete line is not inserted right after the correct project, how would you find which project Compile complete belongs?

Jefe
probably not, but at least it provides readable output. Since msbuild is single-threaded, using it is really nothing more that setting up visual studio to use 1 process at a time, and for that I don't need to do anything special, it can be done thruoptions
galets