Zdieľať cez


Extend SharePoint packaging and deployment

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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

Create 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: Create a custom deployment step for SharePoint projects.

Create 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: Create 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:

Handle 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 Troubleshoot SharePoint packaging and deployment.

Customize 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