This post is regarding the usage of a simple script to automate the wsp installation and featue activation. Whenever we want to deploy components like custom web parts, custom user control and custom application pages etc. we use sharepoint solution packages for deployment and then we activate the respective features manually. It is a tediou job to install the wsps and activate the features manually, if we have multiple solution packages to be deployed. To automate this, we can use the the following script to install wsp and activate features.
:begin @echo off set solutionName=SampleSolution set featureSampleFeature1=SampleFeature1 rem ** Replace this value with the URL of your site ** @set url=http://yourserver/sites/rootsite/subsite @set PATH=C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12BIN;%PATH% stsadm -o retractsolution -name %solutionName%.wsp -immediate stsadm -o execadmsvcjobs stsadm -o deletesolution -name %solutionName%.wsp -override echo Adding solution %solutionName% to solution store... echo ---------------------------------------------------- stsadm -o addsolution -filename %solutionName%.wsp if errorlevel == 0 goto :deploySolution echo ### Error adding solution %solutionName% echo . goto end :deploySolution echo Deploying solution %solutionName%... echo ---------------------------------------------------- stsadm -o deploysolution -name %solutionName%.wsp -url %url% -immediate -allowGacDeployment -allowCasPolicies -force stsadm -o execadmsvcjobs if errorlevel == 0 goto :activateFeature echo ### Error deploying solution %solutionName% echo . goto end :activateFeature echo Activating features in solution %solutionName%... echo ---------------------------------------------------- stsadm -o activatefeature -name %featureSampleFeature1% -url %url% -force if errorlevel == 0 goto :success echo ### Error activating features echo . goto end :success echo Successfully deployed solution and activated feature(s).. echo . goto end :end pause
In the above mentioned script, you can replace the solutionName with the name of your WSP and SampleFeature1 with the name of your feature to be activated. In this example, i'm activating a single feature.
You can also mention multiple features in the script, so that multiple feature gets activated using this script.
Pingback: Script to automate the installation of wsp and activation of features - My experiments with SharePoint, Azure and .NET using Visual Studio