views:

45

answers:

1

We build using MSBuild2005 with a self-written Logger class that keeps track of which projects are currently building and assigns the incoming errors/warnings to the projects. This was a kind of tricky because MSBuild also calls ProjectStarted/FinishedEventArgs when it "somehow" accesses referenced projects. But I got it working.

Now we want to switch to MSBuild2008. Everything works fine until we turn on parallel builds (/m:2 or higher; This is a feature I waited for!). My understanding was, that I can keep track of the parallel tasks by watching the ThreadId property in the BuildEventMessages. But this doesn't work as expected as soon as you enable parallel builds. I got the case where one project was build on ThreadId 1 and another starts on ThreadId 5. But after that a third program starts at ThreadId 5! Curiously those projects behave "stack like": the second finishes before the first. So I thought: may be ok, but how can I assign the errors. To check that I inserted erroneous code into one project. And the result was: the error message had a totally new ThreadId (not 1 or 5 but 6)!

So my question is: How can I assign the error/warning messages to the projects?

A: 

Fond the answer myself:

In .Net 3.5 the BuildEventArgs class contains a new property BuildEventContext which contains a ProjectContextId. This is unique at a time and allows exact assignment.

rstevens