This guide shows the deployment process of Web Parts in basics words.
This post is part of my SharePoint 2010 Development training:
What is deployed?
Deploying a Web Part involves the following components:
Definition of the customization that is deployed
- Elements.xml, defining:
- Which Web Part belongs to the feature
- Where to upload in the Site Collection
- Web Part definition, *.webpart or *.dwp referenced by the elements.xml including e.g.
- A title
- An assembly reference
- Safe Control
Web Parts need an entry in the web.config so the code will be executed
Code of the Web Part
Where is deployed?
If the feature is deployed to a Web Application it becomes available at the scope Site Collection. The feature.xml, the elements.xml and the Web Part files (*.webpart, *.dwp) are written to the file system in the features folder.
Assemblies are deployed to the Global Assembly Cache (GAC) and the web.config is modified with entries in the safe control section.
If you activate the feature the declaration in elements.xml will be executed which contains the upload of the *.webpart and *.dwp files to the Web Parts Gallery on the Site Collection root.
Only after the upload a Web Part becomes available if you click “Add a Web Part” on your site:
Things to know!
- Assemblies of Web Parts can be deployed to the bin folder or the solution gallery too.
- If you retract the feature the *.webpart and *.dwp files will remain in the Web Parts Gallery.
- If you change properties in the Web Part definition *.webpart upgrading the solution won’t show the changes. You need to retract, remove, install and deploy the solution.
- If you add new Web Part definitions to the feature upgrading the solution won’t upload the new definition to the Web Parts Gallery. You need to deactivate and activate the feature or retract, remove, install and deploy the solution again.