16

I have tried adding <Message> elements to tasks in a Visual Studio project file, in order to debug the build process. However, the elements have no effect on the text that is written to the Visual Studio output window.

Is there a way to write messages to the Visual Studio output window, by adding markup to the project being built?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mackenir
  • 10,801
  • 16
  • 68
  • 100

3 Answers3

31

This may help:

Under ToolsOptionsProjects and SolutionsBuild and Run, there’s the MSBuild project build output verbosity combo box. This controls how much info you want to see in the Output window.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nikola Smiljanić
  • 26,745
  • 6
  • 48
  • 60
  • 4
    Thanks, that did it. Even with Importance="high", Messages don't get written out to the Output window by default. – mackenir Jan 15 '10 at 18:07
  • Let it also be noted that if your custom task dll is built with the Release configuration, Debug.WriteLine's will be ignored. You must build in Debug for this to work. I just confirmed that – dario_ramos Aug 12 '11 at 17:59
1

In your project properties → Build Events, you can add something like this in the Post-build event command line:

echo This is my message, no quotes required!

And then you'll be able to see it in the Output after a successful build (if configured to run on a successful build, which is my case).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andres
  • 3,324
  • 6
  • 27
  • 32
-1

I think this should work (it used to for me): <Message Text="blah" />

(And of course, from code, System.Diagnostics.Debug.WriteLine("blah");)

Ariel
  • 5,752
  • 5
  • 49
  • 59
  • Debug.WriteLine() outputs to the debug console at *run-time* – Serge Wautier Jan 15 '10 at 22:35
  • That's why I put "from code" above, right? Even more, nothing prevents you from writing a custom msbuild extension and use System.Diagnostics.Debug.WriteLine(), right? – Ariel Jan 15 '10 at 23:10