Installing SharePoint 2010 RTM on Windows 7 x64

I’ve seen several messages on support forums lately about people having problems trying to install SharePoint 2010 RTM on top of Windows 7 x64 to create a development environment.  The problems seem to stem from changes that have been made to the custom installation sequence required since documentation was written for the BETA.  The Win7 Beta install instructions don’t work quite right for the RTM version.  Microsoft updated the instructions on Technet today (April 30th), but I think they can still be somewhat intimidating since the cover Win7, Vista, and VM installations.  So I thought I would boil them down to just a simple Win7 install and include pictures.  Here are the instructions I’ve tested.  Hope they help you.

Before you Install SharePoint

1. Install Windows 7 x64. Please Note: You can’t use either the K or KN edition (Korean)

2. Install the WCF Hotfix for Microsoft Windows (KB976462). The hotfix is available here: http://go.microsoft.com/fwlink/?LinkID=166231

3. Install the ADO.NET Data Services Update for .NET Framework 3.5 SP1 to enable REST (KB976127). It’s available here: http://www.microsoft.com/downloads/details.aspx?familyid=79d7f6f8-d6e9-4b8c-8640-17f89452148e&displaylang=en

4. Xcopy the SharePoint installation files from the DVD to a folder on your harddrive. If you downloaded them as an executable extract the files using the following command for SPF:

{path to EXE}\SharePoint.exe /extract:{subdirectory}

{path to EXE}\SharePoint.exe /extract:{subdirectory}

or this for SPS:

{path to EXE}\OfficeServer.exe /extract:{subdirectory}

5. Edit the installation configuration file called config.xml located in the \files\Setup\ folder under the subdirectory where you copied or extracted the setup files. Add the following line to the <Configuration> section:


<Setting Id="AllowWindowsClientInstall" Value="True" />

Note: These settings are Case Sensitive. Be very careful with your edits.

6. Install the following included prerequisite:

Microsoft FilterPack Beta – Found in the PrerequisiteInstallerFiles\FilterPack directory where you copied or extracted your files. Run FilterPack.msi

7. Download and install the following prerequisites:

8. Go to Control Panel > Programs and Features > Turn Windows features on or off and enable the following Windows 7 Features:

Win7Features

9. Restart Windows 7 to activate the new feature set.

Install SharePoint Foundation or SharePoint Server

10. To install SharePoint Server 2010 or SharePoint Foundation 2010, run Setup.exe from the folder where you extracted the files.

11. Accept the Microsoft Software License Terms.

1SPF license

12. Choose an installation type. Standalone is the easiest and sufficient for many Developers. You will need a SQL server available if you choose to do a Server Farm install.

2InstallType

13. Once the installation is complete, you are prompted to run the SharePoint Products and Technologies Configuration Wizard. Click the Close button to complete the installation and configure SharePoint.

4SPSwizard

14. After a minute or two the SharePoint Products and Technologies Configuration Wizard will start. Click Next.

15. You will see a dialog box warning you that Windows 7 is not supported for production environments. Click OK

5Win7Unsupported

16. Next you will see a dialog box warning you that some Services will be stopped. Click Yes.

17. You will see a dialog box with a progress bar. Wait for the installation to be complete.

6Progressbar

18. You should see a Configuration Successful dialog when the install is completed. Click Finish and SharePoint will launch the Central Admin website. You can now create additional SharePoint sites as needed and install your development tools.

7success

You can now create additional SharePoint sites as needed and install your development tools.

You can see the full instructions on Technet here:

http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx

Editing a SharePoint Master Page in Visual Studio 2010

I’ll be the first to agree that the best tool for editing a SharePoint master page is SharePoint Designer (SPD).  SPD is able to display both a code and “WYSIWYG” view of the master even if objects on the page are referenced using virtual directories, relative addresses, or addresses that contain dynamic placeholders.  Because Visual Studio can’t open a SharePoint site in place it is unable to provide the same level of editing support. But the problem is that a master page edited in SPD is “customized” and can only be used for that one site (or a single site collection if publishing features have been enabled.) So it has become a best practice to create a custom master in a separate SPD development environment, export it to the file system, and then deploy it in production as an “uncustomized” master page using a feature in a solution. (I documented how to deploy an SPD 2007 master page as a feature in a previous blog here.)

Editing master pages in SPD 2010 continues to be the best practice, but it can be cumbersome for small changes to Enterprise master pages already deployed via a Feature. Sometimes its just not practical to upload the master to a Development site master page gallery, edit it in SPD 2010, and then download the edited copy to be packaged in Visual Studio 2010 and re-deployed to an Enterprise. In those cases it would be nice to make a quick edit in VS 2010. But VS 2010 is unable to interpret the master page in the context of a live site and defaults to the standard code view editor when opening a master page.  This leads to two specific limitations that make even simple edits more difficult.  As you can see from the screen shots below there is no support for expansion/contraction of code sections and Intellisense support is greyed out.

NoExpansion

NoIntellisense

This makes it even more difficult to edit master pages in a code only view. To avoid these limitations you will need to tell VS 2010 which editor to use when opening the master page.  To do this Right-Click on the Master page to be edited in the Solution Explorer and select Open With… from the context menu.  A dialog will open showing all the different Editors that are available.  Highlight the Master Page Editor (Default) entry and click OK to open the Master page using the Master Page Editor in place of the Source Code (Text) Editor.  (Note: Although the Master Page Editor is set as the default just clicking on the master page in Solution Explorer will actually use the Source Code (Text) Editor.  The screenshot below shows the master page after it has been manually loaded into the Master Page Editor using the Open With… menu.  Notice the presence of both Expansion/Contraction Outlining and Intellisense.

MasterPageEditor

A similar problem exists when opening .aspx pages that are not stored in the _Layouts virtual directory.  You can enable full code editing of these pages by using OpenWith… and choosing Web Form Editor (default).

Adding Custom Web Part Page Templates

I was recently asked whether it was possible to add custom Web Part Page templates to the Create page in SharePoint 2007 or whether the interface was limited to the eight existing Web Part Pages and required you to replace one of those.  I knew this was possible in SharePoint 2003 and that there was an MSDN article entitled Creating Custom Web Part Page Templates for Microsoft SharePoint Products and Technologies that explained how to do it.  But since I had never tried it in 2007 I decided to investigate.

It turns out that the answer isn’t a simple yes or no.  The link on the Create page uses a page called  spcf.aspx to list out the web part templates.  Although you can easily add a ninth template to the list the page uses owssvr.dll to instantiate the new web part page and it seems to be hard coded to only accept templates numbered 1 through 8.  So you can’t simply create a custom copy of spcf.aspx with a modified list of Web Part Page templates.  But there is still a way to implement a set of Custom Web Part Page templates.

Interestingly enough if you follow the directions in the SharePoint 2003 MSDN article mentioned above and use the files downloaded from the article you can make this work.  The spcf.aspx file in the article download does not use owssvr.dll and is not limited to only 8 templates.  The problem is that this file was designed for SharePoint 2003 and continues the look and feel of that product.  You also have to make allowances for some path changes since the 2003 product.  So I decided to update the custom page to use a SharePoint 2007 Master Page and relist the steps in the article with modifications for the SharePoint 2007 environment.

NOTE: In addition to updating the custom creation page for a Master Page environment certain code changes were also required.  You must use the custspcf.aspx code available for download from this BLOG as a starting point to make this work.

Steps to add Custom Web Part Page Templates

  • Download custom creation page (custspcf.aspx) from here and copy it 12 hive on your Web front end servers.  The file should be copied to the following directory Local_drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS\1033.   (Note: If you are running on a server installed in a language other than English replace 1033 with the Language Code Identifier for your language.)
  • Open the new custspcf.aspx file in Visual Studio or another suitable text/html editor.
  • Search for onetidWebPartPageTemplate in the custspcf.aspx file.  This is the ID of the selection list for the Web Part Page templates.  There are two selections already included for the file, one for Custom1.aspx (set to be the default selection) and the other for Custom2.aspx.  If you only want two custom templates skip step 4.
  • To add additional templates increment the size attribute of the Select element to the number of choices in the list and duplicate the second Option element in the list.  Change the name value of the Option element using a pattern of Custom#, where # is the next index in the list of selections.
  • Add the new custom Web Part Page template, named Custom# to match the entry in step 4, to the Local_drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\1033\STS\DOCTEMP\SMARTPGS directory.  
  • Copy an image file named Custom#.gif for each of the Web Part Page templates you wish to add where # is the number of the template in the list to Local_drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS\1033\IMAGES
  • Add a Link to custspcf.aspx to the Create.aspx page stored in the Local_drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS directory.  NOTE: You may need to put a copy of this page back in the future so make sure you have a backup copy before editing it.    To add the link search for onetidWebPartPage.  Go to the next tag and insert the following code block immediately after the tag, but before the start of the "/>".
      1: <table style="padding: 3px 0px 3px 4px;" class="ms-itemstatic" onclick="javascript:NavigateInnerHref(event)" onmouseover="this.className='ms-itemhover';ShowListInformation('"
    
      2:   <SharePoint:EncodedLiteral runat="server" EncodeMethod="EcmaScriptStringLiteralEncode" Text=""
    
      3:   <%$Resources:wss,viewlsts_wp_page_title%>
    
      4:     "/>','<SharePoint:EncodedLiteral runat="server" EncodeMethod="EcmaScriptStringLiteralEncode" Text=""<%$Resources:wss,viewlsts_wp_page_desc%>
    
      5:       "/>','/_layouts/images/ltsmrtpg.gif')" onmouseout="this.className='ms-itemstatic';HideListInformation()" cellspacing="0" cellpadding="0" width="100%" border="0">
    
      6:       <tr>
    
      7:         <td valign="top" nowrap="" class="ms-descriptiontext" style="padding-top:1px">
    
      8:           <IMG src="/_layouts/images/setrect.gif" width="5px" height="5px" alt=""
    
      9:           <SharePoint:EncodedLiteral runat='server' text=''
    
     10:           <%$Resources:wss,viewlsts_wp_page_desc%>' EncodeMethod='HtmlEncode'/>">&nbsp;
    
     11:         </td>
    
     12:         <td valign="top" width="100"% class="ms-descriptiontext">
    
     13:           <a id="onetidCustWebPartPage" href="Custspcf.aspx" target="_self">
    
     14:             <SharePoint:EncodedLiteral runat="server" text="Custom Web Part Page" EncodeMethod='HtmlEncode'/>
    
     15:           </a>
    
     16:         </td>
    
     17:       </tr>
    
     18:     </table>

That’s all you need.  The next time you browse to the Create page you will see a link to Custom Web Part Page.  When you click that link you will see a page that looks like the regular creation page for Web Part Pages, but this one will have your custom templates on it. Even better you will be able to add more than 8 to the list and it will continue to work.  Just like it did in SharePoint 2003.

Adding Useful Visual Studio External Tools

We add a couple of External Tools to our Visual Studio 2005 environment when teaching SharePoint classes to simplify some two common tasks encountered when developing for SharePoint.  The first tool generates a unique Globally Unique Identifier (GUID) and places it in your clipboard so that you can paste it directly into Features or Solution manifests.  The other tool can retrieive the Public Key BLOB and Token from a signed dll so that you can use them in custom webpart or dwp files, safe control entries, or custom code access security policies.  Integrating these tools into the menu of Visual Studio makes using them much more convenient than the command line alternatives.

Recently a student asked for a step by step guide to adding these external tools so they can add them to their own development environment.  Rather than simply respond back to them by email I thought it would be worthwhile to document the steps here for others who might also be interested.

Implementing guidgen.exe

  1. Select External Tools from the Tools menu in Visual Studio 2005.
  2. Click Add to add a new external tool to the menu.  You will see the following dialog box.

    External Tools

  3. Fill in the following:
         C&reate GUID for Title
         C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\guidgen.exe for Command
         C:\Program Files\Microsoft Visual Studio 8\Common7\Tools for Initial directory

  4. Click OK to save the new menu entry.
  5. Select Create GUID from the Tools menu and you will see the following dialog:

    Create GUID

  6. Be sure to select GUID Format #4, Click the New GUID button, and then the Copy button.  The GUID is now in your clipboard paste buffer. 
  7. Exit the tool and paste your GUID into Visual Studio.  (Note: be sure to remove the braces from the outside of the GUID since they aren’t needed.)

Implementing SN.exe

  1. Select External Tools from the Tools menu in Visual Studio 2005.
  2. Click Add to add a new external tool to the menu.  You will see the following dialog box.
  3. Fill in the following:
         &Get Token for Title
         C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe for Command
         -Tp "$(TargetPath)" for Arguments
  4. Select the Use Output Window checkbox
  5. Click OK to save the new menu entry.
  6. Once you’ve built your project select Get Token from the Tools menu while one of your code files is open in the code editor and you will see something like the following in your Output Window:

    Output Window

  7. You can now highlight and copy either the Public key token or the Public key BLOB for use in your code.

Feature to Install a Custom Master Page

A former student brought an excellent BLOG post that Heather Solomon made last October (http://www.heathersolomon.com/blog/articles/servermstpageforsitecollect_feature.aspx) to my attention recently.  Heather demonstrated how to create a Feature that could be used to install a Custom Master Page for a Site Collection.  There was however one limitation to the approach that Heather used, it could only be used on a Site where the Publishing Feature was enabled.  My student wondered if there was a way to do something similar for regular WSS Team Sites.

Normally, I teach students how to do this by planning ahead and creating or modifying Site Definitions BEFORE you create the Site Collection and Top Level Site.    The MasterUrl and CustomMasterUrl attributes represent two replaceable parameters that can be used to set the Masterpage attribute of the @Page declaration on the pages of a SharePoint site.  “Out of the Box“ .aspx pages point to a Masterpage at ~/masterurl/default.master. This will be replaced at runtime by the MasterUrl property of the Website.  The default setting for this is _catalogs/masterpage/default.master.  This is the default.master file in the Master Pages gallery of the website.  Until you edit this file using SharePoint Designer it will point to a ghosted copy of the file in the TEMPLATE\GLOBAL directory of the 12 hive.  You can also ghost custom .Master files from your Site Definition directory into the Masterpage gallery of the site using a Module Element.  Then you can set the MasterUrl and/or CustomMasterUrl attributes of the Configuration Element in the ONET.xml file to point at these ghosted .Master files.  If you also change the @Page directive of the .aspx files on your site to use ~/masterurl/custom.master you will establish a hierarchy of master pages that will be used.  The page will first try to use the customMasterUrl setting, then the masterUrl setting, and finally the default.master file in GLOBAL.

Making these changes later will NOT result in a change to existing Sites, but you can also set the MasterUrl and CustomMasterUrl properties of a Website programmatically.  So I reasoned it would be possible to create an Event Handler that would fire when a Feature was activated to set these properties and then move the .Master files using a Feature Module.  Activating this Feature on a site would accomplish the same changes outlined above by a custom site definition.  Here’s how it can be done.

First, we need a Feature. To create our Feature we need a Subdirectory Called CustomMaster in the TEMPLATE\FEATURES directory of the 12 hive.  Then we need add 4 files to this directory:  Feature.xml, Elements.xml, Custom.master, and myDefault.master.

FEATURE.XML This file is used to identify the feature and list out the items that will be part of the Feature.  Our Feature will include an assembly that will contain code to run in response to Feature events and an Elements.xml file.  The code for our Feature is listed below:

   1:  <?xml version="1.0" encoding="utf-8" ?>
   2:  <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
   3:           Id="90969656-A1C9-4f40-A95F-A3BDDF5723BF"
   4:           Title="Use Custom Master File"
   5:           Scope="Web"
   6:           ReceiverAssembly="CustomMaster, Version=1.0.0.0,
   7:               Culture=neutral, PublicKeyToken=bcee0f83b26fbb16"
   8:           ReceiverClass ="CustomMaster.ChangeMaster" >
   9:      <ElementManifests>
  10:          <ElementManifest Location="Elements.xml"/>
  11:      </ElementManifests>
  12:  </Feature>

ELEMENTS.XML – In this file we will identify two .Master files that will be ghosted to the masterpages gallery of the site.

   1:  <?xml version="1.0" encoding="utf-8" ?>
   2:  <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   3:      <Module Name="AddMasters" Url="_catalogs/MasterPage" >
   4:          <File Url="MyDefault.master" Type="GhostableInLibrary"
   5:            IgnoreIfAlreadyExists="True">
   6:            <Property Name=“ContentType
   7:               Value=“$Resources:cmscore,contenttype_masterpage_name;" />
   8:          </File>
   9:          <File Url="custom.master" Type="GhostableInLibrary" 
  10:            IgnoreIfAlreadyExists="True">
  11:            <Property Name=“ContentType
  12:               Value=“$Resources:cmscore,contenttype_masterpage_name;" />
  13:          </File>
  14:    </Module>
  15:  </Elements>

MYDEFAULT.MASTER and CUSTOM.MASTER – These are copies of the default.master file from the TEMPLATE\GLOBAL directory of the 12 hive.  If your .aspx page references the master file ~/masterUrl/default.master then myDefault.master will be used.  If you reference ~/masterUrl/custom.master then Custom.Master will be used.  WARNING: Do not use SharePoint Designer to edit files stored in the 12 hive.  This would break the files.

The last piece of the Feature is a Feature event handler that will be used to modify the masterUrl and customMasterUrl properties of the Website programmatically.  The event handler will set the properties when the Feature is activated and reset them to the default when the Feature is deactivated.  The code for the event handler is listed below:

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Text;
   4:  using Microsoft.SharePoint;
   5:   
   6:  namespace CustomMaster
   7:  {
   8:      public class ChangeMaster:Microsoft.SharePoint.SPFeatureReceiver 
   9:      {
  10:          public override void FeatureInstalled
  11:            (SPFeatureReceiverProperties properties)
  12:          {
  13:          }
  14:          public override void FeatureUninstalling
  15:             (SPFeatureReceiverProperties properties)
  16:          {
  17:          }
  18:          public override void FeatureActivated
  19:             (SPFeatureReceiverProperties properties)
  20:          {
  21:              SPWeb CurrentWeb = properties.Feature.Parent as SPWeb;
  22:              CurrentWeb.MasterUrl = "/_catalogs/masterpage/MyDefault.master";
  23:              CurrentWeb.CustomMasterUrl = "/_catalogs/masterpage/custom.master";
  24:              CurrentWeb.Update();
  25:          }
  26:          public override void FeatureDeactivating
  27:             (SPFeatureReceiverProperties properties)
  28:          {
  29:              SPWeb CurrentWeb = properties.Feature.Parent as SPWeb;
  30:              CurrentWeb.MasterUrl = "/_catalogs/masterpage/default.master";
  31:              CurrentWeb.CustomMasterUrl = "/_catalogs/masterpage/default.master";
  32:              CurrentWeb.Update();
  33:         }
  34:      }
  35:  }
  36:   

Once the event handler has been compiled and added to the Global Assembly Cache and the Feature directory has been created you can Install and Activate the Feature.  To install the Feature use the following command line:

stsadm -o installfeature -n CustomMaster

Then you can go to the Site Features link in SiteSettings on any SharePoint website and activate the Feature.  Every website where the Feature is activated will use the myDefault.master stored in the Feature as its .master file.  If you modify the @Page declaration of a page on the site to use ~/masterUrl/Custom.master then the Custom.master will be used.

*** Updated July 3, 2008 ***

I noticed recently that I left one line out of the Elements.xml file which prevented the feature from working in Site Collections where Publishing was turned on.  In those sites the master pages gallery contains two content types so you have to specify what type of file you are "ghosting" with your .  The Code that was added is italized in the code listing above.