SPVisualDev: Working with features

I thought I´d make a quick post describing (showing off this wonderful tool) how use SPVisualDev to add a new feature, or in this example I´m going to change the settings on a feature that I have already added (not using SPVisualDev). The procedure is the same though.

I´ll start by pulling up the context menu and clicking “feature settings”.

There are a couple of choices (tabs) presented. I´m going to add a feature receiver so I´ll click on the “Code” tab.
Here is where you set the default folder where the code files (fe event receivers) are placed. I have also changed the default namespace that my feature receiver class will have. To choose the folder I´ll click the “Pick” button.
You don´t have to do this but since I´m going to show off the add-in I´m going to do it this way.

After I click “Pick” this dialogue (above) is shown. Drill down to my feature and choose the root folder of the feature. (since I don´t want to have my code files in a separate directory which is default).

OK, next I´m going to switch to the “General” tab.

Down in the properties window I will click on the “…” button on the “ReceiverClass” property.

A new dialogue is shown where I can do a couple of things but since I´m going to add an event receiver I´ll click the “Add feature event receiver” button.

SPVisualDev now will now synchronize all the changes I have made to the feature.xml file and thus adding all the xml for adding a feature receiver.

Finally a .cs file with all the necessary code to start implementing the feature receiver is placed for me in the feature folder.

Debugging feature receivers

This is one these times where I simply love SPVisualDev. Let´s say that I want to debug my feature receiver.

Look, I haven´t written a line that says System.Diagnostics.Debugger.Launch() I have inserted a break point just as I was in plain old asp.net.
Maybe we can call it the POAN way, with a reference to POCO and POJO. If you are in to DDD you´ll get that reference.

The only “different” thing I have to do is to fire off the feature through SPVisualDev. I can live with that since the code still needs to run in SharePoint (duh) and I don´t have to use the UI.

And…yepp the break point has been hit and I can debug my code.

This is great, I mean how many times have you written those System.Diagnostics.Debugger.Launch() lines and then forgot to take them out before checking in. OK I haven´t but… 😉