Thursday, July 8, 2010

Post-Build Event Script in Visual Studio

When doing SharePoint development its good to choose on-the-fly whether I want to compile for the sake of making sure my code is compilable or to verify that my code deploys/activates successfully to a website. To accomplish this I've created a Post-Build Event script for my project as follows.


if $(ConfigurationName) == Debug GOTO DoDebugSkip
DEL "$(TargetDir)$(ProjectName).wsp"
"C:\Program Files\WSPTools\WSPBuilderExtensions\WspBuilder" -SolutionPath "$(ProjectDir)" -OutputPath "$(TargetDir)"

ECHO ON
call "c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
gacutil /u $(ProjectName).dll
gacutil /i $(TargetDir)$(ProjectName).dll
@set PATH=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH%

stsadm -o deactivatefeature -filename $(ProjectName)\Feature.xml -url http://localhost/
stsadm -o execadmsvcjobs
stsadm -o retractsolution -name "$(ProjectName).wsp" -allcontenturls -immediate
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name "$(ProjectName).wsp" -override
stsadm -o execadmsvcjobs

stsadm -o addsolution -filename "$(ProjectName).wsp"
stsadm -o execadmsvcjobs
stsadm -o deploysolution -name "$(ProjectName).wsp" -url http://localhost -immediate -allowGacDeployment -allowCasPolicies -force
stsadm -o execadmsvcjobs
stsadm -o activatefeature -filename $(ProjectName)\Feature.xml -url http://localhost/
stsadm -o execadmsvcjobs
stsadm –o copyappbincontent
stsadm -o execadmsvcjobs

iisreset
:DoDebugSkip

1 comment:

  1. Nice information you shared regarding SharePoint technologies and I think everyone should remember.
    Offshore .NET Development

    ReplyDelete