Article Series Content
- Basics of Farm Level SharePoint Deployment and Retraction (This Article)
- Step by Step Building Deployment and Retraction PowerShell Script
- Final Version of Deployment and Retraction PowerShell Script
- Step by Step Using PowerShell Script in Batch Files
If you have been developing custom solutions on SharePoint 2010 platform, having knowledge of how to move your code from developer’s machine to server environment using scripts is mandatory. It’s been best practice for a while to script deployment process while moving code to server environment. It always surprises me seeing developers manually logging on the servers and run PowerShell commands to deploy/retract custom solutions and activate/deactivate features. If you are SharePoint administrators, it is most important that you would ask your development team to standardize the deployment process using scripts.
During SharePoint 2007, STSADM was available to script the custom solutions deployment/retraction process. In SharePoint 2010, Microsoft has introduced PowerShell as preferred technology to script custom solutions deployment/retraction process. This blog series will outline what are the major steps required for farm level custom solution deployment and retraction process for SharePoint 2010, how you can automate the process using PowerShell, and how you can automate the deployment execution using windows batch files.
This is first part of this article series and it provides the overview of the SharePoint 2010 Farm Level Solution deployment/retraction process.
In SharePoint 2010, both Solutions and features can be managed by Browser Interface, PowerShell, or STSADM. You must be farm administrators to manage farm level features, Manage Web permission at the root level site (site collection administrator) to manage site collection features, and Manage Web permission (site owners) to manage site level features.
Following two tables outlines what is supported and commands available at the browser, STSADM, and PowerShell.
|Solutions Actions||Central Admin (System Settings-> Farm Management -> Manage Farm Solutions)||PowerShell||STSADM|
|View Solutions||Yes||Get-SPSolution||-o enumsolutions|
|Add Solution – Add Solutions to Farm Solutions Gallery||Not Supported||Add-SPSolution||-o addsolution|
|Deploy Solution – Deploys Solutions to the web applications||Yes||Install-SPSolution||-o deploysolution|
|Update Solution – Update the deployed solution||Not Supported||Update-SPSolution||-o upgradesolution|
|Retract Solution – retract solutions from the web applications||Yes||Uninstall-SPSolution||-o retractsolution|
|Remove Solution – Remove the solution from the farm solutions gallery||Yes||Remove-SPSolution||-o deletesolution|
|Feature Actions||Farm, Application, Site, and Web Level Features Page||PowerShell||STSADM|
|View Features – View features at the farm, web application, site collection, or site scope||Yes||Get-SPFeature||Not Supported|
|Install Feature – Install feature at the farm, web application, site collection, or site scope||No||Install-SPFeature||-o installfeature|
|Activate Feature – Activate feature at the farm, web application, site collection, or site scope||Yes||Enable-SPFeature||-o activatefeature|
|Deactivate Feature – Deactivate feature at the farm, web application, site collection, or site scope||Yes||Disable-SPFeature||-o deactivatefeature|
|Uninstall Feature – Uninstall feature at the farm, web application, site collection, or site scope||No||Uninstall-SPFeature||-o uninstallfeature|
- Add Solution – Add-SPSolution
- Adds a SharePoint solution package to the farm Solution gallery, It doesn’t deploy the uploaded solution yet.
- Add-SPSolution -LiteralPath “c:\Project Initiation Web Parts.wsp”
- Deploy Solution – Install-SPSolution
- Deploys an installed SharePoint solution on all the WFE servers in the farm. This command also installs all the features on each server at the farm, web, site collection, and site level but It doesn’t activate them.
- Since it provisions the file on each WFE, it is a timer job. It may take while to provision the files.
- Install-SPSolution –Identity “Project Initiation Web Parts.wsp” –WebApplication http://sp2010vm -GACDeployment
- Major Parameters
- Identity – Name of the fully trusted solution
- AllWebApplications or Web Application with URL – URL of the web application where solution will be deployed. For Global deployment for all web applications, specify AllWebApplications
- Local – Solution will be deployed on only server where this command is being run
- GACDeployment – To deploy artifacts into GAC
- Time – Schedule the solution deployment at specified time. If this parameter is not specified, solution deployment process would run immediately during next timer job process
- Major File System changes
- Global Assembly Cache – C:\Windows\assembly (e.g. Deploys the DLL into GAC)
- Web Application Directories – C:\inetpub\wwwroot\wss\VirtualDirectories (e.g. Updates the web.config and adds web part safe control entries – C:\inetpub\wwwroot\wss\VirtualDirectories\80)
- SharePoint Root Folder – C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14
- Adds new feature directory and provision the web part files – C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\
- Adds new user controls – C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\
- Install Feature – Install-SPFeature (Optional Step – included in Install-SPSolution)
- Deploying solution in the farm installs the feature automatically. This is preferred method. No need to manually run this command.
- Install-SPFeature <FeatureFolderName>
- Activate Feature – Enable-SPFeature
- Enables installed SharePoint Feature at the given scope. If the feature is a farm feature, no URL is needed. Otherwise, provide the URL where the feature is to be activated (explicit scope is not needed).
- Enable-SPFeature –identity “MyCustomFeatureNameorGUID” -URL http://sp2010vm
- Identity parameter is feature folder name or feature GUID
- Update Solution – Update-SPSolution
- Upgrades a deployed SharePoint solution in the farm. Use this cmdlet only if a new solution contains the same name, same set of files, and features as the deployed solution.
- If files and features are different and feature version is not upgraded, the solution must be retracted and redeployed by using the Uninstall-SPSolution and Install-SPSolution cmdlets, respectively.
- Update-SPSolution -Identity contoso_solution.wsp -LiteralPath c:\contoso_solution_v2.wsp -GACDeployment
- Deactivate Feature – Disable-SPFeature
- Disables installed SharePoint Feature at a given scope. If the scope of the Feature is the farm, the URL is not needed. Otherwise, provide the URL at which this Feature is to be deactivated (explicit scope is not needed).
- Disable-SPFeature –identity “MyCustomFeatureNameorGUID” -URL http://sp2010vm
- Identity parameter is feature folder name or feature GUID
- Uninstall Feature – UnInstall-SPFeature (Optional Step – included in UnInstall-SPSolution)
- Retracting solution in the farm uninstalls the feature automatically. This is preferred method. No need to manually run this command unless solution retraction process couldn’t uninstall features for some reasons.
- UnInstall-SPFeature <FeatureFolderName>
- Retract Solution – Uninstall-SPSolution
- Retracts a deployed SharePoint solution from the farm entirely for all web application or given web application. If web application is not specified, this cmdlet removes files from all the front-end Web server.
- Since it removes the file on each WFE, it is a timer job. It may take while to delete the files.
- Uninstall-SPSolution –Identity “Project Initiation Web Parts.wsp” –WebApplication http://sp2010vm
- Most items that go in the content database are not overwritten or deleted for you when the feature reinstalls or solutions are retracted. Most items that go on the file system are overwritten or deleted during the retraction process. There is exception to this rule – redeploying web parts deletes the web part from the web part gallery and imports the new updated version, if web part deployment conflict resolution property is set to the Automatic. Other options are None to ignore over write and prompt.
- Removes deployed components from the file system
- Deletes the DLL from the GAC – C:\Windows\assembly
- Updates the web.config and removes web part safe control entries – C:\inetpub\wwwroot\wss\VirtualDirectories\80
- Deletes the feature directory – C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\ProjectInitiationToolWebParts_ProjectInit
- Delete Solution – Remove-SPSolution
- Deletes a SharePoint solution from a farm solution gallery
- Don’t deploy the solution when its being removed by this command. It may put the solution in the inconsistent state. Always verify that solution is removed from the farm solution gallery before kicking off the deploy process of same solution.
- Remove-SPSolution -Identity “Project Initiation Web Parts.wsp”
That concludes this overview article. Hopefully you have gained enough knowledge of SharePoint 2010 custom deployment and retraction process. Next article in this series will discuss steps required to build PowerShell script to automate the deployment/retraction solutions process.