Home > development, MOSS, MS SharePoint Sever, sharepoint, sps > STSADM, WSPBuilder and GACUTIL Deployment Commands

STSADM, WSPBuilder and GACUTIL Deployment Commands

Here is a quick reference for STSADM and WSPBuilder deployment commands. You can use individual commands or make a batch file as given below:

STSADM Batch File:

Save the following in a notepad as “StsadmDeployment.bat” file:

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o retractsolution -name "YourSolution.DeploymentPackage.wsp" -immediate -allcontenturls
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o execadmsvcjobs
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o deletesolution -name "YourSolution.DeploymentPackage.wsp"
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o execadmsvcjobs
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o addsolution -filename "YourSolution.DeploymentPackage.wsp"
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o execadmsvcjobs
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o deploysolution -name "YourSolution.DeploymentPackage.wsp" -immediate -allcontenturls -allowGacDeployment -allowCasPolicies -force
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o execadmsvcjobs

You might have noticed that commands above has -allcontenturls parameter. This is to deploy the package to all nonadministrative virtual servers that are in the farm. If you dont like it, here is the batch file withouth this parameter:

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o retractsolution -name "YourSolution.DeploymentPackage.wsp" -immediate
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o execadmsvcjobs
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o deletesolution -name "YourSolution.DeploymentPackage.wsp"
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o execadmsvcjobs
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o addsolution -filename "YourSolution.DeploymentPackage.wsp"
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o execadmsvcjobs
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o deploysolution -name "YourSolution.DeploymentPackage.wsp" -immediate -allowGacDeployment -allowCasPolicies -force
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o execadmsvcjobs

Put the batch file in the same folder as your .wsp file.

WSPBuilder Batch File:

If you wish to use WSPBuilder instead of STSADM, here is the batch file:

Save the following in a notepad as “WSPBuilderDeployment.bat” file:

"C:\Program Files (x86)\WSPTools\WSPBuilderExtensions\wspbuilder.exe" -WSPName YourSolution.DeploymentPackage.wsp -BuildWSP false -deploy true

Put the batch file in the same folder as your .wsp file.

Installing the DLL in GAC (Batch File):

What’s this. So, when you are working in a development environment, you have already deployed your solution to sharepoint farm (which is a one time operation only), and now you are making changes to your code and dragging/dropping ur DLL into GAC, doing an IISRESET and moving to your sharepoint site and testing the changes you made (a.k.a as debugging more or less :)). So, lets make this dragging/dropping of DLL and IISRESET a double click process:

Save the following in a notepad as “GACInstall.bat” file:

iisreset
gacutil /i YourSolution.dll
iisreset
pause

Put the batch file in the same folder as your .dll file.

Note here that “gacutil.exe” has a path set in PATH environment variable. So, for example my gacutil.exe is placed here:

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin

In Windows Server 2003, I’ll go to My Computer, take its properties, go to Advanced tab, click Environment Variables, double click ‘Path’ in the System Variables list of variables, put a semicolon (;) at the end and copy/paste the above path. Do not leave any spaces before and after the semicolon (;). Now you dont need to go to ‘C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin’ all the time to run gacutil.exe. You can run this in a command prompt from any path. This path should be set in order for “GACInstall.bat” to run. You may not like that extra IISRESET at line no. 1 in “GACInstall.bat”. Its there only just in case, you may remove it if you like.

Look for your gacutil.exe somewhere here:

  • %programfiles%\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\gacutil.exe
  • %programfiles%\Microsoft SDKs\Windows\v6.0\Bin
  • %programfiles%\Microsoft SDKs\Windows\v6.0A\Bin
  • %windir%\Microsoft.NET\Framework\v1.0.3705
  • %windir%\Microsoft.NET\Framework\v1.1.4322

Gacutil.exe comes with .Net SDK (a free download). It is not part of the basic redistributable. SDK is installed with Visual Studio, so if you have Visual Studio, you should have Gacutil.exe.

Similarly, if you wish you can also set paths for STSADM.exe and WSPBuilder.exe and remove those long paths from the batch files above.

Now you only have to double click one of these batch files and the rest is all automatic :).

Hope this helps–

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: