Share via


Extending SharePoint Packaging and Deployment

You can extend the packaging and deployment process for SharePoint projects.

This topic contains the following sections.

  • Creating Deployment Steps
  • Creating Deployment Configurations
  • Run Code When a SharePoint Solution is Deployed or Retracted
  • Handling Deployment Conflicts
  • Run Command Line Operations Before or After a Project is Deployed
  • Customizing Validation Rules
  • Related Topics

Creating Deployment Steps

When you deploy a SharePoint project, Visual Studio executes a series of deployment steps. Visual Studio includes built-in deployment steps for many tasks, such as retracting and adding solutions. However, you can also create your own deployment steps.

For a walkthrough that demonstrates how to create a deployment step, see Walkthrough: Creating a Custom Deployment Step for SharePoint Projects.

Creating Deployment Configurations

A deployment configuration is a set of deployment steps that is executed for a given project but can affect all SharePoint project items. Every deployment configuration includes one set of steps that is executed when the project is deployed, and another set that is executed when the project is retracted. Visual Studio includes two built-in deployment configurations, but you can also create your own. When you create a deployment configuration, you can include built-in deployment steps and deployment steps that you create.

For a walkthrough that demonstrates how to create a deployment configuration, see Walkthrough: Creating a Custom Deployment Step for SharePoint Projects.

Run Code When a SharePoint Solution is Deployed or Retracted

You can handle events to perform additional tasks when a SharePoint solution is deployed or retracted. Visual Studio raises events that you can handle in the following scenarios:

Handling Deployment Conflicts

Some types of SharePoint project items, including modules, Web parts, list instances, and content types, provide built-in deployment conflict resolution. When you deploy a solution that contains one of these project items, Visual Studio first checks whether a file already exists on the SharePoint site with the same name, URL, or ID as a file in the item you are deploying. If a conflict exists, Visual Studio can automatically resolve the conflict, or it can prompt you to determine whether you want to have Visual Studio resolve the conflict or cancel the deployment. For more information, see Troubleshooting SharePoint Packaging and Deployment.

You can extend this feature by providing your own code that checks for and resolves deployment conflicts. For more information, see How to: Handle Deployment Conflicts.

Run Command Line Operations Before or After a Project is Deployed

If you want to run a command line operation when a SharePoint solution is deployed, you can set the PreDeploymentCommand and PostDeploymentCommand properties of an ISharePointProject object. Visual Studio executes these commands before and after the project is deployed.

In some cases, you may see deployment conflicts. There are several different ways to resolve conflicts. For more information, see Troubleshooting SharePoint Packaging and Deployment.

Customizing Validation Rules

Before you deploy a solution package (.wsp), you can create custom Feature and package validation rules to verify that the Feature or package is valid. For example, you can report information, warnings, or errors to developers to help them fix validation problems. For more information, see How to: Create Custom Feature and Package Validation Rules for SharePoint Solutions.

See Also

Tasks

Walkthrough: Creating a Custom Deployment Step for SharePoint Projects

How to: Create Custom Feature and Package Validation Rules for SharePoint Solutions

Concepts

How to: Run Code When Deployment Steps are Executed

Extending the SharePoint Project System