Visual Studio 2010 Bugger

The default Visual Studio 2010 debugger is more of a de“bugger” sometimes, which bothers you with wanting to debug all the executable code in your server, like owstimer.exe for example.

This happens whenever the SharePoint 2010 Timer Service is restarted and VS2010 intercepts and wants you to debug it.

Follow this link to turn it off.

Download files from Content Database

Problem

Compare master page content from two content databases, modified independently.

Pre-conditions

In a SharePoint migration project, was in a situation where the content of the application in two diffrent servers (say dev vs test) had changed independently. In other words, dev cdb was modified, so was the test cdb. And both changes were almost valid. I had to individually pick and choose changes from dev and test and merge into a single source. And there were several such files.

SharePoint Designer 2010 exibhits a Vedantic property of being the best, not-so-best and neither both all at the sametime. In other words, the goodness in you can never the triumph the evil of SPD and will eternally continue to fight with it.

Modifying each file and merging would be cumbersome, especially when SPD usually likes to mind its own business when you want it to respond. So I decided to download the files from both content databases locally, then use a sophisticated compare tool like Beyond Compare or WinMerge, merge them and upload it back to the content database.

Solution

Microsoft must have finally shed some sense of shame and hired a few Unix guys who probably are behind PowerShell. So here comes PowerShell again to the rescue to do that effortlessly.

#
$url = "http://yoursite"
$masterPageGallery = "/_catalogs/masterpage"
$destPath = "c:/site1"
#
$site = Get-SPSite($url)
$webs = $site.AllWebs
$rootWeb = $site.RootWeb
#Get the MasterPageGallery folder
#Another way to get MPG is $rootWeb.GetCatalog(116)
$folder = $rootWeb.GetFolder($masterPageGallery)
$files = $folder.Files
foreach ($f in $files) {
 [Byte[]] $fBytes = $f.OpenBinary()
 #Store the name explicitly for creating DestPath;
# by default $f := $f.Url, not $f.Name
 $fileName = $f.Name
 $destFile = "$destPath/$fileName"
 [System.IO.File]::WriteAllBytes($destFile, $fBytes)
}