March 23, 2011

WSPBuilder Project - SharePoint 2007

1. File --> New Project --> WspBuilder Project
2. Add existing item [ Shared Signin Key if you have one, otherwise create one]
3. Delete default signin key.
4. Add any other existing items, like GlobalInfo.cs
5. Create Deployment Folder
6. Add existing Install and Remove Scripts and modify as per the current features and wsp.
7. Add READMe.txt of what the solution does.
8. Add WSPBuilder.exe which has the settings for the build.
9. Add wspbuilder.ExcludedFiles.txt to exclude dll's which are already in the GAC or BIN.
Note: Change the Application Target Framework as per your need, 3.5 is good.
10. Now add whatever you need like Features, Workflows, EventHandler etc.

Files:

1. GlobalInfo.cs

[assembly: System.Security.AllowPartiallyTrustedCallers()]

2. WSPBuilder.exe
Note: DLLReferencePath : 80\BIN means it gets the dlls from the solution 80\bin folder
          Deployment Target: GAC (or) BIN (or) Auto

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="BuildDDF" value="true" />
    <add key="TraceLevel" value="3" />
    <add key="Cleanup" value="false" />
    <add key="BuildWSP" value="true" />
    <add key="BuildMode" value="Release"/>
    <add key="Outputpath" value="DeploymentFolder" />
    <add key="BuildSafeControls" value="true"/>
    <add key="IncludeAssemblies" value="true" />
    <add key="BuildCAS" value="false" />
    <add key="DLLReferencePath" value="80\BIN" />
    <add key="Excludefiletypes" value="ignore,spsource" />
    <add key="DeploymentTarget" value="GAC" />
    <!-- don't add dlls that are already in the portal. -->
    <add key="ExcludeFiles" value="wspbuilder.ExcludedFiles.txt" />
    <!--
    Optional settings
    You can set the arguments in this file or use them directly in the console.
    All arguments has a defualt value. See wspbuilder -help
   
    <add key="BuildCAS" value="true" />
    <add key="CustomCAS" value="CASPolicy.txt" />
    <add key="DLLReferencePath" value="80\BIN" />
    <add key="CustomCAS" value="CASPolicy.txt" />
    <add key="12Path" value="" />
    <add key="80Path" value="" />
    <add key="BinPath" value="" />
    <add key="BuildCAS" value="" />
    <add key="PermissionSetLevel" value="" />
    <add key="BuildSafeControls" value="" />
    <add key="Createfolders" value="" />
    <add key="DeploymentTarget" value="" />
    <add key="Destination" value="" />
    <add key="DLLReferencePath" value="" />
    <add key="Excludefiletypes" value="" />
    <add key="ExpandTypes" value="" />
    <add key="Help" value="" />
    <add key="IncludeAssemblies" value="" />
    <add key="IncludeFeatures" value="" />
    <add key="Includefiletypes" value="" />
    <add key="ManifestEncoding" value="" />
    <add key="ResetWebServer" value="" />
    <add key="Silence" value="" />
    <add key="SolutionId" value="" />
    <add key="SolutionPath" value="DeploymentFolder" />
    <add key="WSPName" value="" />

    TraveLevel switch controls the general messages. In order to
         receive general trace messages change the value to the
         appropriate level.
         Possible values :
         "0" gives no messages
         "1" gives error messages
         "2" gives errors and warnings
         "3" gives information
         "4" gives verbose information
      
     The default value in WSPBuilder is Information (3).
    -->
  </appSettings>
</configuration>

3. Install Script:

echo off
@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm.exe"
@SET SOLUTION=SolutionName.wsp
@SET FEATURE=SolutionName
@SET URL=http://server:port
cls
ECHO OFF
ECHO -------------------------------------------------------------------------------
ECHO Deactivate Feature if it exists
ECHO -------------------------------------------------------------------------------
%STSADM% -o deactivatefeature -name %FEATURE% -url %URL% -force
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Retract the solution if it exists
ECHO -------------------------------------------------------------------------------
%STSADM% -o retractsolution -name %SOLUTION% -immediate -url %URL%
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Deleting the solution...
ECHO -------------------------------------------------------------------------------
%STSADM% -o deletesolution -name %SOLUTION% -override
%STSADM% -o execadmsvcjobs
rem pause
ECHO -------------------------------------------------------------------------------
ECHO Adding the solution...
ECHO -------------------------------------------------------------------------------
%STSADM% -o addsolution -filename %SOLUTION%
IF %ERRORLEVEL% NEQ 0 goto removeError
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Deploying the solution.
ECHO -------------------------------------------------------------------------------
%STSADM% -o deploysolution -name %SOLUTION% -immediate -allowgacdeployment -url %URL% -force -allowCASPolicies
IF %ERRORLEVEL% NEQ 0 goto removeError
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Activate Feature
ECHO -------------------------------------------------------------------------------
%STSADM% -o activatefeature -name %FEATURE% -url %URL% -force
IF %ERRORLEVEL% NEQ 0 goto removeError
%STSADM% -o execadmsvcjobs
goto removeSuccess

:removeError
ECHO *** FAILURE ***
ECHO --------------------------------------------------
pause > nul
goto :deployDone
:removeSuccess
ECHO *** SUCCESS ***
:deployDone

4. RemoveScript

echo off
@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm.exe"
@SET SOLUTION=SolutionName.wsp
@SET FEATURE=SolutionName
@SET URL=http://server:port
cls
ECHO OFF
ECHO -------------------------------------------------------------------------------
ECHO Deactivate Feature if it exists
ECHO -------------------------------------------------------------------------------
%STSADM% -o deactivatefeature -name %FEATURE% -url %URL% -force
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Retract the solution if it exists
ECHO -------------------------------------------------------------------------------
%STSADM% -o retractsolution -name %SOLUTION% -immediate -url %URL%
%STSADM% -o execadmsvcjobs
ECHO -------------------------------------------------------------------------------
ECHO Deleting the solution...
ECHO -------------------------------------------------------------------------------
%STSADM% -o deletesolution -name %SOLUTION% -override
%STSADM% -o execadmsvcjobs
rem pause

5.  Note: SPContext in feature activation doesn't work while running the script.
 For that you have to use, workflowproperties.feature as Site(or)Web depending on the feature scope.

No comments:

SonarQube with Jenkins Setup using Docker Images

https://funnelgarden.com/sonarqube-jenkins-docker/  https://medium.com/@hakdogan/an-end-to-end-tutorial-to-continuous-integration-and-con...