views:

184

answers:

2

I just wrote a little program which will be executed as a post-build step when I compile certain projects.

This program returns 0 for success, or some number for failure. In case of failure, Visual Studio then correctly outputs: "The command [...] exited with code n."

However, a single number is not always helpful. In my case, I actually want the error to point to a specific place in the source code. Is it possible to output a filename and line number in such a way that Visual Studio will actually let me just double-click on the error and get there instantly?

A: 

You need to write your own Visual Studio extension.

Andrejs Cainikovs
+12  A: 

If the program you're running is a console application, I think its output will appear in the output pane. If the output is of the form

D:\dev\project\Code\MyClasscpp(68) : something terrible happened

then you can double-click on the line and the editor will open on the indicated line.

Regards,

Sebastiaan

Sebastiaan Megens
Nice, tested it, works like a charm.
Am
You can also output to Console.Error for it to show up in the Error List.
Tinister
You can also output this format in a Trace.WriteLine while debugging an application. Double-click and all just works.
csharptest.net
Tinister's comment is slightly inaccurate. It will show up in the Error List only if after the filename and line number it also says "Error:" or "Warning:", e.g. D:\dev\project\MyClass.cs(68): Error: Something terrible happened.
Timwi