问题
I have a custom MSBuild task that takes some time to complete. It outputs progress using either Log.LogMessage() or BuildEngine.LogMessageEvent() (tried both).
My problem is that all output doesn't appear in VS2012 Output window until the task is completed, making progress updates useless. I would like to have output appearing while the task is running, right away.
I found various threads explaining to call frequently Application.DoEvents(), but that doesn't seem to solve the problem (maybe it only applied for VS2010 and before?).
回答1:
Known bug in VS2012.
We ended up making a VSPackage extension for VS2012/2013 (to directly output in pane log).
It is fixed in VS2015.
回答2:
It is a bug in VS 2012. In the comments in this bug report a user whose alias is Will, speaking on behalf of Microsoft, wrote on July the 2nd of 2013 that Though we will not have a chance to address this issue in Visual Studio 2012, we will consider this feedback when planning for future versions of Visual Studio.
来源:https://stackoverflow.com/questions/16690071/custom-msbuild-task-how-to-flush-logging-in-vs2012-output-window-while-task-is