Skip to main content

Thinking out aloud - Dave Hunter's SharePoint Blog

Go Search
Home
Blog
  

Locations of visitors to this page


 Useful Links

  Microsoft UK events
  SharePoint 2007 on CodePlex
  SharePoint Community Portal
  SharePoint User Group
  SharePoint Community Portal
  SharePoint Pedia
  SharePoint MSDN Forums
  SharePoint University
Home > Thinking out aloud - Dave Hunter's SharePoint Blog > Posts > Upload Masterpages and Page Layouts with STSADM Custom Command
My thoughts and findings on Microsoft Information worker technologies, including MCMS and SharePoint 2007 (MOSS).
Upload Masterpages and Page Layouts with STSADM Custom Command

When developing sites for SharePoint using solution deployment (WSP) you think about provisioning of masterpages and page layouts using features, like the one below:

<Module Name="MasterPages" Url="_catalogs/masterpage" Path="sourcefolder">

<File Url="CustomSite.master" Type="GhostableInLibrary">

<Property Name="Title" Value="Custom Site Masterpage" />

<Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name" />

</Module>

But what happens when the site is deployed and you need to make changes to masterpages and page layouts ...

1. You cant create a feature like the one above with IgnoreIfAlreadyExists.

<Module Name="MasterPages" Url="_catalogs/masterpage" Path="sourcefolder">

<File Url="CustomSite.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">

<Property Name="Title" Value="Custom Site Masterpage" />

<Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name" />

</Module>

This fails with file already exists, even though the IgnoreIfAlreadyExists property is specified.

2. You can edit using SharePoint Designer, but if you don't have access to SharePoint Designer you are out of options. 

3. You could upload these to the gallery in SharePoint if you have permissions.

4. You can use STSADM Export / Import but this will bring over all content.  I prefer to make the deployment footprint as small as possible.

I decided to create a custom STSADM command which will modify the existing files or add new ones if they don't exist.  The STSADM command is called "UploadMasterPagesAndPageLayouts" and accepts the following parameters

operation_uploadmpagesandplayouts

Here is an example of the usage:

STSADM -O uploadmasterpagesandpagelayouts -url http://intranet -folder "c:\deploy" -comment "uploaded by a tool" -version  "major" -autoapprove

This will upload all files in the deploy folder to http://intranet as major versions and approved. The only optional parameter is the autoapprove flag, by default this is leave unapproved.

Download the extension here http://uploadplmp.codeplex.com/Release/ProjectReleases.aspx

  Copyright
This work is licenced under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.0 UK: England & Wales License
  Site Map

Comments

There are no comments yet for this post.

 Dave Hunter

I'm currently a Senior Consultant at Netstore 2e2. I specialise in Microsoft Information Worker technologies (especially MOSS, MCMS and .NET), with over 8 years of experience within this area of specialism. 

I have gained two certifications for MOSS and WSS and look to complete the full certification track soon.

View Dave Hunter's profile on LinkedIn

  Subscribe in a reader


 Latest Posts

I’ve been Awarded a MVP for SharePoint01/04/2010 19:49
SharePoint 2010 Training on Microsoft E-Learning15/03/2010 17:56
SharePoint UK User Group - Thursday 27th August London Meeting25/08/2009 17:56
CAML Query that filters on the current user23/07/2009 17:50
Microsoft Ramp Up Free SharePoint Developer Training22/07/2009 20:59
How To: Change a SharePoint Application Pool Programmatically07/07/2009 18:08
SharePoint Forums Topping 100 Answers06/07/2009 12:29
Find out the SharePoint Internal Name for a Column or Site Column28/05/2009 09:56
Delving into Deploying SharePoint Artifacts with Features24/04/2009 15:20
SharePoint - Connecting MySites with the Portal24/04/2009 14:39
1 - 10 Next