Writing testable SharePoint code: New Zealand and Australian SharePoint Conferences

This year I was lucky enough to be invited back to present at the New Zealand and Australian SharePoint Conferences, this time on “Writing Testable SharePoint Code”. As promised in my sessions here is the slide deck and, more importantly, the sample code :)

Posted in Conferences, Development, SharePoint, Visual Studio | Leave a comment

Design Manager and Server 2008 R2

I was trying to use the design manager features today and ran into this on my dev server. I’d copied the short cut from the screen and pasted it into the map network folder dialog and got this:

image

 

If you’re trying to do this from Server 2008 R2 you’ll need to do a simple piece of config first; Simply go and add the Desktop Experience Feature and reboot your server!

A nice and easy fix :)

Also make sure you use the http:// path and not the file:// path that you’ll get with right click > copy shortcut ;)

Posted in Uncategorized | Leave a comment

Setting up Visual Studio 2012 for SharePoint 2013

VS2012 Update 1 is great it adds the Microsoft Fakes framework for stubbing out SharePoint dependencies and other really useful tools for SharePoint development. If you’re using Visual Studio 2012 you should be using Update 1; but it doesn’t have the extensions for 2013 development as yet. To get those they need to be installed using the web platform installer.

1) Download and install http://www.microsoft.com/web/downloads/platform.aspx (you should probably do this for all development environments anyway)

2) Launch the Web Platform Installer and search for SharePoint

3) Add install the latest version of the “”Microsoft Office Developer Tools for Visual Studio 2012” (currently it’s Preview 2)

Posted in Development, SharePoint, Tools | Leave a comment

PowerShell: Pause for specific key strokes

Today I needed to add a wait into a Powershell script, given that is a point where the user running the script needs to go do some manual steps on another server I thought it might be a good idea to wait for a specific key press. So off to Bing I go…

There are plenty of great articles on waiting for or getting user input, personally I really like Windows PowerShell Tip of the Week: Pausing a Script Until the User Presses a Key and the User Interaction chapter from the PowerShell Cookbook. After seeing that [Console]::ReadKey() would give me an object which told me about the modifers on the key press (Crtl, Alt and/or Shift) I started thinking about making that key press more specific, say Ctrl + G, so I wrote a function to handle this:

function Pause
{
	param([string] $pauseKey,
			[ConsoleModifiers] $modifier,
			[string] $prompt,
			[bool] $hideKeysStrokes)
			
    Write-Host -NoNewLine "Press $prompt to continue . . . "
    do
	{
		$key = [Console]::ReadKey($hideKeysStrokes)
	} 
	while(($key.Key -ne $pauseKey) -or ($key.Modifiers -ne $modifer))	
	
    Write-Host
}

This function received a bit of inspiration from How to Properly Pause a PowerShell Script which itself is pretty interesting.

Things to note:

Ctrl + C will still cancel the script, you’ll need to use $host.UI.RawUI.ReadKey with the AllowCtrlC option to prevent that, but then accessing the Modifiers is done differently.

$modifers is a simple enum value of ConsoleModifiers if you want to do combinations like Atl+Shift you’ll pass a collection of modifers and do –band operations to see if your conditions are met.

To call the Pause function use something like this:

$modifer = [ConsoleModifiers]::Control
Pause "G" $modifer "Ctrl + G" $true  

And then you’ll see this: image

Posted in Uncategorized | Leave a comment

I’m an MVP for SharePoint Server!

Wahooo!

A couple of weeks ago I got one of the coolest emails I’ve received in my professional career, it read:

Dear Gavin Barron,
Congratulations! We are pleased to present you with the 2012 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in SharePoint Server technical communities during the past year.

I’m really happy receive this honour! I’d really like to thank everyone at Intergen for the support they’ve provided over the years and for an environment where community involvement is encouraged. I’d like to personally call out Chris, Chan, Debbie, OJ and Brendan for their personal support and help since I first got involved with this crazy SharePoint thing.

It’s been a heck of a ride so far and with the public preview of Office 2013 announced this morning I’m looking forward to the next few months.

-Gavin

Posted in Personal, SharePoint | Leave a comment

Whitespace: Silent Killer!

Today I went hunting in an XML file for an erroneous double space I knew was there. 

Space_horror

I was horrified to see all those extra spaces there!!! Now this Visual Studio 2010 instance is just running the default setup with the productivity tools installed (Oh and I hit Ctrl+R, Ctrl+W to show the whitespace characters used)

FileSize_With_Spaces

That’s an 81KB XML file!

Now I’m a believer in tabs over spaces and full tab sized indents in all cases, to me it’s cleaner and reduces page weight.

So, open up Visual Studios options, Tools > Options and go to Text Editor > All Languages > Tabs. For me this is what I found….

Original_Tab_Settings

Settings that were not consistent across all the file types and Spaces used as indents! Grrrr!!!!! So, a quick change of settings:

New_Tab_settings

A quick Ctrl+A, Ctrl+K, Ctrl+F to re-format the file and things looks much tidier:

Tabs_Not_Spaces

The file size came down to 80KB, so about a 1.25% savings, not a huge amount, but if you think about that over all of the code sitting in source control for a development company like ours that’s likely to be gigabytes worth of savings. Plus the double space in the file stood out nice and clearly!

Now that the preferences for VS are ‘fixed’ all of the files will get the ugly space based whitespace removed as they get worked on.

-Gavin

Posted in Deployment, Visual Studio | 4 Comments

Document Set Limitations and Considerations in SharePoint 2010

First of all, go and read the excellent article Document Set Limitations and Considerations in SharePoint 2010 written by Michal Pisarek.

Ok, you’re back and have read all those? Great! I’ve got a few more for you.

  1. Shared Fields are push down only:

    If you go into a document within a document and edit a property which is set as a shared property for the Document Set that change does not get propagated to the either the containing Document Set or to other documents within the set. If you need to change these across the entire Document Set you must make the change to the Document Set itself and then SharePoint will propagate these changes down.

  2. Versions have to be declared:

    Despite the fact that a Document Set itself can have metadata which users change there is no automatic tracking of changes made. You must use the Capture Version functionality manually to record changes made against the metadata at a Document Set level.

  3. No Check-In/Check-Out functionality:

    The notion of check-in/check-out does not apply to Document Sets. This kind of makes sense when you consider that they are just special folders and a check-out at the folder level would imply that they user had also checked out all child documents. But it’s a little annoying, especially as there is metadata against the Document Set which users can freely edit with no automatic version history captured.

Posted in Caveats, Document Sets, SharePoint | 3 Comments