Q:

return a collection from msbuild custom logger

Is it possible to return an array, list or object out of a custom logger?
I want to add all errors and warnings generated by MSBuild and store them in an array, then pass this array back to my build script and report on it if necessary.
Is this possible?

A:

You cannot do this directly: a logger is passed to the build engine when it's contructed, like on the commandline, and there doesn't seem to be a way to access it afterwards from within an msbuild script. Programmatically, maybe, but again I wouldn't know how to do that. Moreover a logger adheres to the ILogger interface and that's all msbuild sees, so whatever methods you add won't be accessible anyway.
There are workarounds though: see this for example. The trick is that the dll containing your custom logger can be accessed from within msbuild, so if you have a logger collecting events and storing them in a static List in the dll that same list can be accessed using a custom task in the same dll. Make that task return the static List to the msbuild script again as an ItemGroup and you're good to go.

