Friday, 19 February 2010

WSP Feature Deployment and Uninstalling

I need to deploy / uninstall some features which I have created and not having access to the servers and not wanting to create complicated release notes, I came up with the following batch file

it is called with 2 or 3 parameters; the first is the wsp name, the second the server and the third “U” or “u” if you want to uninstall it.

I am sure everyone will have their own bit they want to do, but it is a start.

ECHO OFF

SET wspname=%1
SET wspname=%wspname:.wsp=%

If [%1] == [] GOTO USAGE
If [%2] == [] GOTO USAGE
If [%3] == [U] GOTO UNINSTALL
If [%3] == [u] GOTO UNINSTALL

ECHO ************** INSTALL %1 ***************
ECHO ON

stsadm -o addsolution -filename %1
stsadm -o execadmsvcjobs
stsadm -o deploysolution -name %1 -immediate -allowGacDeployment -force
stsadm -o execadmsvcjobs
stsadm -o activatefeature -filename "%wspname%\feature.xml" -url %2
GOTO END

:UNINSTALL

ECHO ************** UNINSTALL %1 ***************
ECHO ON
stsadm -o deactivatefeature -filename "%wspname%\feature.xml" -url %2
stsadm -o retractsolution -name %1 -immediate
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name %1 -override
stsadm -o execadmsvcjobs

GOTO END

:USAGE
ECHO Parameter 1 = wsp filename, for example myfeature.wsp
ECHO Parameter 2 = site, for example http://myserver:1000
ECHO Parameter 3  u or U = uninstall

:END
ECHO OFF
ECHO Done please check for errors

No comments:

Post a Comment