Not a direct answer as I don't think I ever solved that either. I chose to create and write to a new output window. Should be of some help to you, see the WriteLine method at the bottom of this source: http://code.google.com/p/csharptest-net/source/browse/src/Tools/CmdTool/VsInterop/BaseCodeGeneratorWithSite.cs
I think OutputTaskItemString might even do what you are asking.