Visual Studio integrated custom MSBuild task behav

2019-04-02 11:18发布

问题:

I was looking around the net for a NUnit custom MSBuild task that would run on every build and also nicely play with Visual Studio UI (2008 is my version). I found MSBuild.Community.Tasks project that was great, but failed in Visual Studio integration part. What I actually wanted to have is get failed tests displayed as warnings/errors in VS's error list window (and also FAILED project build when tests are not successful). So I wrote my own custom MSBuild task that does the job exactly how I wanted it to be.

BUT.

The only problem that I have is that normal VS UI error list behaviour is that when you click on an error it jumps to appropriate source file and highlights the problematic code. I was able to relate file and line number with failed test however I wasn't able in any way to persuade Visual Studio to HIGHLIGHT problematic code for me (when I double click the error). All I get is cursor in the right spot. I tried all kinds of combinations of line, endLine, column, endColumn method parameters (Log.LogError()), but to no avail. And based on error output by compiler errors it looks like it also provides just line and column (no end values).

Anybody ran against this oddity and solved it?

Update 13 May 2009
You can get this project for free (without method selection) at
http://code.google.com/p/nunitmsbuildvsintegrated/

回答1:

For this feature, you must create Visual Studio Integrated Package that display custom panel in Visual Studio. This custom panel will be called when your project is built.

Visual Studio Extensibility Developer Center



回答2:

I have no solution to your exact problem, but have some thoughts.

Are you sure you want to run a full suite of unit tests at the end of each and every build? I personally find it to be a productivity killer. Rather, while working with code I tend to run a small subset tests which cover only the code in question, and this is where tools like ReSharper or TestDriven.NET come into play.


(source: jetbrains.com)