Monday, April 11, 2011

Visual Studio & SharePoint: how to create package as part of the build process

In order to build a project and have the package created, this can be added to the project file (csproj, vbproj):
<PostBuildEventDependsOn>
$(PostBuildEventDependsOn);
CreatePackage;
</PostBuildEventDependsOn>

Monday, April 4, 2011

SharePoint 2010: PowerShell to delete a web part from the gallery

param($Identity = "", $Url = "")

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.WebPartPages")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")


$SPSite = New-Object Microsoft.SharePoint.SPSite($Url)

$SPWeb = $SPSite.OpenWeb()
$WebPartGallery = $SPWeb.Lists["Web Part Gallery"]
$gall = $WebPartGallery.Items select Name
$count = $gall.Count
for ($i =0; $i -lt $count;$i++)
{
if ($gall[$i] -match $Identity)
{
$WebPartGallery.Items.Delete($i)
$SPWeb.Update()
Write-Host "$Identity deleted"
$SPWeb.Dispose()
}
}

Wednesday, March 30, 2011

VMWare player: blank full screen on Windows 7

Solution: enable "Accelerate 3D graphics."

Friday, March 4, 2011

BitLocker: get out of recovery mode

Some changes to BIOS will cause bitlocker to enter recovery mode.

One way to get out of this follows:

- enter the 8 groups of 6 digits
- get into Windows
- type "manage-bde -protectors -disable c:" from a admin command prompt
- reboot
- type "manage-bde -protectors -enable c:" from a admin command prompt
- reboot

It shouldn't prompt now.

See here for details.

Thursday, March 3, 2011

SharePoint: list throttling messages

There are two messages that people often get when throttling limits (5K default) is reached.

"Displaying only the newest results below. To view all results, narrow your query by adding a filter.": this is seen when metadata navigation and filtering is enabled for the list.

"This view cannot be displayed because it exceeds the list view threshold (5000 items) enforced by the administrator.": this is seen in all other cases.

Wednesday, February 9, 2011

SharePoint 2010: code for dumping a taxonomy tree

Just customize the data you need from each node type (store, group, set, term).
        private void DumpTaxonomy(string siteUrl)
{
Stack<string> stack = new Stack<string>();
using (SPSite site = new SPSite(siteUrl))
{
TaxonomySession session = new TaxonomySession(site, false);
int nts = 0;
foreach (TermStore ts in session.TermStores)
{
nts++;
int ng = 0;
foreach (Group g in ts.Groups)
{
ng++;
int ns = 0;
foreach (TermSet s in g.TermSets)
{
ns++;
int nt = 0;
foreach (Term t in s.Terms)
{
nt++;
DumpTerm(t, stack, 4);
}
stack.Push(ReportNode(3, nt));
}
stack.Push(ReportNode(2, ns));
}
stack.Push(ReportNode(1, ng));
}
stack.Push(ReportNode(0, nts));
}
while (stack.Count > 0)
{
Console.WriteLine(stack.Pop());
}
}

private void DumpTerm(Term t, Stack<string> stack, int level)
{
int nt = 0;
foreach (Term children in t.Terms)
{
nt++;
DumpTerm(children, stack, level + 1);
}
stack.Push(ReportNode(level, t.Name + " " + nt.ToString()));
}

private string ReportNode(int level, object children)
{
StringBuilder sb = new StringBuilder();
for(int i = 0; i < level; i++)
{
sb.Append("\t");
}
sb.Append(children);
return (sb.ToString());
}