1

I want to redirect output from our code review tool that we are writing in VS2010, so that it's messages are parsed by Vs2010 and we can click on them to goto file, line, column.

I vaguely remember learing about this in vs2005, you output your text to a certain kind of window, with the exact format below, and then vs would parse the message and you could click on it to goto the specific location...

D:\Project Files\CIS3G\Webapp_Test_BLL\Evaluation\Reports\TestEvaluationHistoryBLL.cs(27,44): warning CS0649: Error text

It was constructed thusly :

full file path:[error or warning type]:error message

Then it just worked "magically"..

But this is all I can remember from a conversation ~10 years ago about how to do this. Does anyone remember what I'm talking about and can direct me to information about how to make this work with output from a tool we write to work within visual studio 2010?

Maybe a tutorial?

This post: Formatting the output of a custom tool so I can double click an error in Visual Studio and the file opens

Talks about doing it in the build, but I'd like to be able to run the code review tool independantly and get it to work too...

Community
  • 1
  • 1
Eric Brown - Cal
  • 14,135
  • 12
  • 58
  • 97

2 Answers2

1

You've pretty much got it right in your question.

As an example, create a file in your temp directory (in a command prompt do echo %temp% to find it) called test.bat

Add the following to test.bat:

@echo D:\Project Files\CIS3G\Webapp_Test_BLL\Evaluation\Reports\TestEvaluationHistoryBLL.cs(27,44): warning CS0649: Error text

Now in VS10, select Tools->External Tools.... In the new window, select Add.

In the Command: field, enter %temp%\test.bat

Select Use Output window and click OK.

Your new tool should now show up in VS10's Tools menu. If you click on it, your Output window should display a clickable message, which will open "D:\Project Files\CIS3G\Webapp_Test_BLL\Evaluation\Reports\TestEvaluationHistoryBLL.cs" if it exists, and will put the cursor on line 27 if it exists (if not, line 1) at column 44 if it exists (if not, column 1).

You can go further and add a shortcut key to your custom tool.

Select Tools->Options...->Environment->Keyboard. Find your tool in the list of commands. It will show as Tools.ExternalCommand[x] where [x] is its position in the list of External Tools. Enter your chosen shortcut key(s) in the Press shortcut keys: box and click OK.

Fraser
  • 74,704
  • 20
  • 238
  • 215
1

Here is an article on doing this written in 2004 that still applies today:

http://www.codeproject.com/Articles/6176/Using-the-Output-Window-in-DevStudio

Yes, I wrote it, but as was pointed out earlier, there is nothing particularly magic about this. The article mentions VC6 and VC7, but I still use this technique in VS2005, VS2008, and VS2010 for the output of PC-Lint.

Harold Bamford
  • 1,589
  • 1
  • 14
  • 26