SharePoint development and deployment WSP solution package, sharepointwsp

Source: Internet
Author: User

SharePoint development and deployment WSP solution package, sharepointwsp

Note: In this document, the development tool of SharePoint2013 is based on VS2013. You can also refer to this document for previous versions.

WSP: SharePoint Solution Package.


I. concepts and tools

Let's first introduce the source of WSP. To get a deeper understanding of WSP, you must first start with SharePoint development. The content that can be developed by SharePoint is complex. The latest version of VS2013 contains the basic template of the Sharepoint solution. The process from creation to deployment is simple and easy to use, it is much easier than the previous development solutions. However, you still cannot leave the SharePoint host environment and remote development and deployment. However, a new programming idea for SharePoint is SharePoint APP development. This development mode can be deployed on the client.

After creating the SharePoint solution, engineers program and develop the list library, Web Components, events, website templates, workflows, and other aspects. These functions are Feature, so how can we finally deploy these functions in the SharePoint environment? This requires first packaging the solution into a WSP file, in fact, this WSP file is a cab file and a compressed file. If you are interested, you can use the rar tool to open this file.

There are many methods to package a solution for wsp files. The methods I have used before include:


    • WSPBuilder tool command method, related links CodePlex Project

    • WSPBuilderExtension, a vs plug-in, which is simpler than the above method

    • SharePoint Software Factory (SP | SF), A Visual Studio extension tool. The latest version supports VS2013. The related link is VS extension. CodePlex Project address.

    • Of course, the SharePoint solution developed by VS2013 can be directly deployed from the context menu. The solution is automatically packaged during deployment.

    • Of course, some third-party cab generation tools can also help us generate wsp files, but the operation process is complicated.

The use of these tools is not part of this article. Please pay attention to other related articles on my blog.


Ii. WSP deployment, update, and deletion

Note the following:

Solutions include adding, installing (also known as deployment), updating, revoking, and deleting,

Feature is divided into: activation and deactivation

Add Solution

STSADM and SharePoint PowerShell commands. PowerShell command set is recommended from SharePoint2013.

An example of the STSADM command is as follows (used for elimination ):

> Stsadm-o addsolution-filename <path> \ YourSolution. wsp

PowerShell command example:

> Add-SPSolution-LiteralPath "wsp path \ file name. wsp"

For the added solution, you can deploy the solution in the Management Center:

> Choose "Management Center"> "system settings"> "Management Farm solution". Here, I only introduce the function and do not describe the specific operation. The operation is simple and easy to understand.

Installation (deployment) Solution

> Install-SPSolution-Identity "YourSolution. wsp"-WebApplication "site address"-GACDeployment

Update Solution

> Update-SPSolution-Identity "YourSolution. wsp"-LiteralPath "<path> \ YourSolution. wsp"-GACDeployment-force

Reclaim Solution

> Uninstall-SPSolution-Identity "YourSolution. wsp"

Delete Solution

> Remove-SPSolution-Identity "YourSolution. wsp"

Note: You must revoke the solution before deleting the solution.

Obtain the added Solution

> Get-SPSolution

Unlock the deployment lock of the Solution

> Remove-SPSolutionDeploymentLock

3. Deploy and disable Feature

A solution contains more than one Feature. After the solution is deployed to the site, you can use commands to control the status of each Feature in the solution. The Feature concept corresponds to the schema definition in the Features directory of the SharePoint solution project.

Obtain Feature

> Get-SPFeature

The above command obtains all Feature values in farm and displays "name, GUID, SharePoint function version"

> Get-SPFeature-Identity "<GUID>"

You can obtain the Feature whose ID is GUID,

Install SharePoint

> Install-SPFeature-path "<YourSolution >_< FeatureName>"

Uninstall Feature

> Uninstall-SPFeature-Identity "<YourSolution >_< FeatureName>"

Enable Feature in a given range

> Enable-SPFeature-Identity "<YourSolution >_< FeatureName>"-URL "<siteUrl>"

Disable Feature within a specified range

> Disable-SPFeature-Identity "<YourSolution >_< FeatureName>"-URL "<siteUrl>"

Iv. Sandbox Solutions

> Update-SPUserSolution

> Install-SPUserSolution

> Uninstall-SPUserSolution

> Remove-SPUserSolution

> Get-SPUserSolution

> Add-SPUserSolution

5. Timer Solution

Install AutoSenArvatodMailJob. wsp

1) Add-SPSolution-LiteralPath "c: \ AutoSendMailJob. wsp"
2) Install-SPSolution-Identity "AutoSendMailJob. wsp"-WebApplication <siteUrl>-GACDeployment
3) iisreset

4) Disable-SPFeature-Identity "AutoSendMailJob_Feature2"-Url "<siteUrl>" 5) Enable-SPFeature-Identity "AutoSendMailJob_Feature2"-Url "<siteUrl>"
6) net stop SPTimerV4
7) net start SPTimerV4

Update AutoSenArvatodMailJob. wsp

1) Disable-SPFeature-Identity "Arvato. BBA. AutoSendMailJob_Feature2"-Url "<siteUrl>"

2) Uninstall-SPSolution-Identity "Arvato. BBA. AutoSendMailJob. wsp"-WebApplication "<siteUrl>"-Confirm: $ false
3) Remove-SPSolution-Identity Arvato. BBA. AutoSendMailJob. wsp-Confirm: $ false
4) Add-SPSolution-LiteralPath "c: \ Arvato. BBA. AutoSendMailJob2.wsp"
5) Install-SPSolution-Identity "Arvato. BBA. AutoSendMailJob. wsp"-WebApplication "<siteUrl>"-GACDeployment
6) iisreset
7) Enable-SPFeature-Identity "Arvato. BBA. AutoSendMailJob_Feature2"-Url "<siteUrl>" 8
8) net stop SPTimerV4
9) net start SPTimerV4

3. Delete redundant timer Methods

// View the timer "ArvatoBBASendMailTimerJob"
Get-SPTimerJob |? {$ _. Name-match "ArvatoBBASendMailTimerJob"} | ft id, name
// Set job to a variable
$ Job = Get-SPTimerJob-id 59af3540-7ac0-4477-82f9-1f6ab9829aca
// And delete it.
$ Job. Delete ()


Finally, the wsp file is automatically packaged in the bin \ debug directory of the SharePoint solution of VS2013. To remotely deploy the solution to the enterprise environment, copy the wsp file and write a PowerShell script file for ps1. It can be delivered to the enterprise system administrator for installation.

The PS1 script file can be called and executed by C #. This part will be explained later.

Take compiling the PS1 file of the backup website set as an example:

12 Add-PSSnapin Microsoft.SharePoint.PowerShell backup-spsite -identity $args[0] -path $args[1] -force

This script uses backup-spsite to back up the SharePoint website set, sets the URL and backup path of the website to two parameters, and saves it as a file with the suffix ps1, such as backup. ps1

Write a batch processing script for backup and log writing.

12345678 @echo offSET SOURCE_SITE=SET DEST=C:\backup\RZH-SP-204_%date:~0,10%.bakSET LOG=C:\backup\BackupLog.txtEcho % DATE % time :~, 5%: start backing up the Website: % SOURCE_SITE %> % LOG %powershell -command C:\backup.ps1  %SOURCE_SITE% %DEST%Echo % DATE % time :~, 5%: Website: % SOURCE_SITE % backup completed> % LOG %@echo on

Save the script as a bat batch file

I don't know if you can understand the above Code.

Finally, we will provide you with a complete script to install the wsp solution. If the script is not complete enough, please let us know!

12345678910111213141516171819202122232425262728 Add-PSSnapin Microsoft.SharePoint.PowerShell$solutionName "SharePointProject2.wsp"$webUrl "http://wisdom-moss/"$path Split-Path -Parent $MyInvocation.MyCommand.Definition$solution Get-SPSolution | select nameforeach($s in $solution){    if($s -match $solutionName){        Write-Host -ForegroundColor Green "Solution '$solutionName' was existed."        $deployed Get-SPSolution -Identity $solutionName | select deployed        if($deployed.Deployed){            Write-Host -ForegroundColor Green "Start uninstall solution..."            Uninstall-SPSolution -Identity $solutionName -Confirm:$false -Verbose -WebApplication $webUrl            #sleep 30s, need uninstall over.            Start-Sleep -s 30            Write-Host -ForegroundColor Green "End uninstall solution!"        }        Write-Host -ForegroundColor Green "Start remove solution..."        Remove-SPSolution -Identity $solutionName -Confirm:$false        Write-Host -ForegroundColor Green "End remove solution!"    }}Write-Host -ForegroundColor Green "Start add solution..."Add-SPSolution -LiteralPath ($path '\' +  $solutionName)Write-Host -ForegroundColor Green "End add solution!"Write-Host -ForegroundColor Green "Start deploy solution..."Install-SPSolution -Identity $solutionName -WebApplication $webUrl -FullTrustBinDeploymentWrite-Host -ForegroundColor Green "End deploy solution!"Write-Host -ForegroundColor Green "End all executed."

Note: Because my solution is defined as an assembly deployment target to WebApplication, dll I want to deploy to the bin directory of the website set. If your solution is to be deployed to GAC, to globally deploy the scheme, you need to deploy the assembly to the target GlobalAssemblyCache.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.