SharePoint Web Part Project – Post Build Commands

When you are building a web part project, you might want to do the following tasks :

  • Move the .dll to the GAC
  • Do a Application Pool Recycle

The following are the variables that we can use in our scripts.

Name Description
$(TargetPath) The full directory path to the output directory, including the project output filename. Example: D:\MyWorks\HelloWorld\bin\debug\HelloWorld.dll
$(TargetDir) The full directory path to the output directory. Example: D:\MyWorks\HelloWorld\bin\debug\
$(ProjectDir) The full directory path to where the project file exists. Example: D:\MyWorks\HelloWorld\

Moving the DLL to the GAC :

The location of the gacutil.exe utility in VS 2008  is different from the VS2005 environment.

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

Command : “%programfiles%\Microsoft SDKs\Windows\v6.0A\bin\GacUtil.exe” /if “$(TargetPath)” /nologo

VS2005 : C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin

Command : “%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\GacUtil.exe” /if “$(TargetPath)” /nologo

Recycling Application Pool :

IIS 6 :

“%systemroot%\system32\iisapp.vbs” /a “sharepoint – 80” /r

if CSCRIPT is not the default host then

%windir%\system32\cscript.exe  “%systemroot%\system32\iisapp.vbs” /a “sharepoint – 80” /r

IIS 7:

“%systemroot%\system32\inetsrv\APPCMD” recycle apppools “Sharepoint – 80”

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: