Just wanting to share the utilities, custom scripts and applications that I use when developing for SharePoint.
Besides the obvious, Visual Studio, SharePoint Designer and InfoPath, the following is what I find makes developing and debugging that little bit easier.
Visual Studio
When using Visual Studio, I add a few custom menu items to the Tools menu, the following are my staples:
First up, there’s a menu item for displaying the strong name key for the current assembly.:
The command here references the %programfiles(x86)%\microsoft sdks\windows\v7.0a\Bin\sn.exe file and the following argument -T $(TargetPath). The -T option is used to display the public key token for the assembly given by the TargetPath variable.
Next, I add an option for listing all of the worker processes:
The command this time is C:\Windows\System32\inetsrv\appcmd.exe and the argument list wp.
Running provides an output similar to:
Which makes it easy to identify which w3wp process to connect to when debugging. Using add-ins such as CKSDev allow you to connect to the available IIS processes but not a specific one.
The next three options (To GAC…) all use a custom batch file which looks like:
@Echo Off Echo. Echo Copying %1 to the GAC if "%2" == "1" ( Echo. iisreset /restart net stop SPTimerV4 net start SPTimerV4 ) if "%3" == "1" ( Echo. %windir%\System32\inetsrv\appcmd recycle apppool /apppool.name:"SharePoint - 80" ) Echo. "%Program Files(x86)%\Microsoft SDKs\Windows\v7.0A\Bin\gacutil" /i "%1" /f |
The argument for the To GAC with Reset option is $(TargetPath) 1. This copies the current assembly to the GAC and performs an IIS reset. Again, the CKSDev add-in provides this functionality but you need to copy it first and then reset IIS afterwards, this combines it into the one command.
The argument for the To GAC with Recycle option is $(TargetPath) 0 1. As with the previous command, this also copies the current assembly to the GAC but this time recycles the SharePoint 80 application pool.
The argument for the To GAC with Recycle option is $(TargetPath). This command simply copies the current assembly to the GAC.
The last custom option I use is SP Dispose Check.
First, download the tool from the following site Dispose Check.
Then add the tool using the command %ProgramFiles(x86)%\Microsoft\SharePoint Dispose Check\SPDisposeCheck.exe, argument $(BinDir) and initial directory $(SolutionDir)
OK, that’s it for the Visual Studio tools. Next up, the custom scripts that I use.
Scripts
Only the one script, if you exclude the copy to GAC batch file.
This script request the SharePoint timer job to process. Easier than going into the Central Administration site and manually running the timer job.
First there’s the PowerShell script:
param($url,$timerjobName) $snapinAdded = $false try { if ( (Get-PSSnapin -Name Microsoft.Sharepoint.Powershell -ErrorAction SilentlyContinue) -eq $null ) { $global:snapinAdded = $true Write-Host "Adding Sharepoint module to PowerShell" -NoNewline Add-PSSnapin Microsoft.Sharepoint.Powershell -ErrorAction Stop Write-Host " - Done." } Write-Host "Adding Microsoft.Sharepoint assembly" -NoNewline Add-Type -AssemblyName "Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Write-Host " - Done." Write-Host "" Write-Host "Starting `"$timerJobName`" " -NoNewline $webApp = $null if ($url -ne $null -and $url -ne "") { Write-Host "for $url " -NoNewLine $webApp = Get-SPWebApplication $url } $job = Get-SPTimerJob | where{$_.Name -match $timerjobName} | where{($webApp -eq $null) -or ($webApp -ne $null -and $_.Parent -eq $webApp)} if ($job -eq $null) { Write-Host '- Timer job was not found.' -ForegroundColor Red } else { $job | Start-SPTimerJob Write-Host "- Done." -ForegroundColor Green } } catch { Write-Host "" Write-Host "Error starting timer job $timerJobName: " $error[0] -ForegroundColor Red throw Exit 1 } finally { if ($global:snapinAdded -eq $true) { Write-Host "" Write-Host "Removing Sharepoint module from PowerShell" -NoNewline Remove-PSSnapin Microsoft.Sharepoint.Powershell -ErrorAction SilentlyContinue Write-Host " - Done." Write-Host "" } } |
and the batch file to run the script:
@ECHO OFF Set Url= Set timerJob=job-workflow powershell.exe -Command ".\StartTimerJob.ps1 -url \"%Url%\" -timerJobName \"%timerJob%\" exit $LastExitCode" pause |
Finally, I’ll list the applications and utilities that I use the most.
Apps and Utilities
In no particular order: