Question

I have a webpart project built in visual studio 2010 and it has been deployed successfully to my production environment. I recently had to make some changes to the webpart and also needed to add a new supporting webpart to the project (based on the nature of the webparts and their relationship to each other it, I thought it would make sense to keep both in the same project and therefore part of the same feature).

Anyway, after making the changes I deployed to the server using the command 'update-spsolution'. However, while the changes I made to the already existing webpart were immediately visible on any pages where the webpart was deployed, I am not able to deploy the newly created webpart that was part of the feature, in fact I couldn't even find it in the web part gallery.

It was only afterwards when I removed the new webpart from the existing project and created a brand new project, a brand new wsp file and deploying the new solution and then activating the new feature that i was able to deploy the new webpart.

I'm wondering, is there something I'm doing wrong when running the 'update-spsolution' command that results in my newly added webpart not being available?

Was it helpful?

Solution

You will need to re-activate the feature that you updated. Upon re-activation, the web part should show in the gallery.

OTHER TIPS

If you wanted to do it the "right" way then you should have used Feature Upgrading.

It's unfortunately not simple but gives you a lot of control of what happens when you deploy a new version of a feature.

In your case it would have involved:

  • Add the elements.xml files for the new web parts inside <ApplyElementManifests> inside <UpgradeActions> in the feature.xml
  • update solution using update-spsolution as you did
  • upgrade the features (can be done using SharePoint 2010 Feature Upgrade Kit)

For more information about to Feature upgrade see Chris O'Briens series starting with Feature upgrade (part 1) - fundamentals

Even though it may seem as overkill for a simple project I still think it's the right thing to due for the following reasons:

  • It's a good practise to get into and you should always think upgrading into your features
  • If your feature is doing something when activated/deactivated like adding data or cleaning up then activate/deactivate may not be an option
  • It may be a lot easier to find all the places to upgrade a feature (build in) than to loop though and look for where feature is activated and then deactivate/activate

I've found updating wsp's can be a little tricky sometimes. Sometimes doing a full Uninstall-SPSolution/Remove-SPSolution will help if you are experiencing strange behavior.

In my experience deploying form visual studio usually goes off without a hitch. Because of this, I will try to match it's deploy process as closely as possible if I am having a deploy problem. Below is a description of the "Default" deploy configuration for a SharePoint project in visual studio:

... packages the WSP file, recycles the application pool, retracts the previous version of the solution, adds the solution, activates all features, and runs the post-deployment command line.

You will need to re-activate the web parts from web part Gallery go to site Actions> Site settings under Galleries > Web parts in the Web parts Gallery documents >new document you will fine the new web parts select the new web parts and click Populate Gallery in the new web part Edit Properties Change the group to Custom and click save after that you will fine the new web parts in the custom web parts

Upon deactivate and then activate and finally recycle application pool solve my problem.Now the web part is shown in gallery.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top