The commands for installing the features are part of the deployment process in Visual Studio. There are no flags or properties that you can set to debug this event in the Feature Receiver. In this recipe, we will guide you through the step-by-step process to accomplish this task.
Retract the solution if it was already deployed to a site.
Uncomment the FeatureInstalled method and press F9 to put in a break point.
Build the solution and package it.
From the command prompt use
stsadmto add solution to solution store and deploy it as described in the recipe Deploying the Event Receivers. Follow the steps 8 and 9 in that recipe to deploy the solution.
In the Visual Studio, go to project properties from menu Project | FeatureEventReceiver Properties.
In the Debug tab, set the external program to
Enter the command line arguments in the same tab as follows:
-o installfeature –name FeatureEventReceiver_Feature1 –force
Your debug tab should be similar to the one shown in the following screenshot:
In here, we
are manually attaching an external process to the Visual Studio debugger. In our case,
STSADM.exe is our external program. We did the preliminary work of adding the solution to the solution store and deploying the solution. We bypassed the entire deployment process that Visual Studio uses, so we can debug our Feature Receiver.
By default, Visual Studio provides two configurations: the Default configuration and the No Activation configuration. You cannot edit those configurations. None of these configurations are good for our purpose here. What we needed was a configuration that just deploys the solution without installing it. So we created an empty configuration and resorted to a manual process to debug this solution.
Use the same process as used previously to debug the uninstalled event in the Feature Receiver. In step 8, substitute command line arguments as follows:
-o uninstallfeature –filename FeatureEventReceiver_Feature1\Feature.xml