SharePoint 2010 Tricks: MapFile Element
Hello everyone and welcome to another exciting blog post in the SharePoint Gems series. It’s been some time since the last one and this is the first for SharePoint 2010. The goal of SharePoint Tricksis to shed some light on unknown features in SharePoint. Most of the time, those features have little to no documentation on msdn and are not really feature in posts on the net. So, it’s always nice to find a bit of info, right here.
On my current job, I’m working on a migration to SharePoint 2010. SharePoint 2010 features a couple of new items towards migration and upgrading and it’s in this last category I’ve found a gem.
As most of you know, features can be upgraded now. Unfortunately this procedure is quite cumbersome and contains a lot of manual steps (customactions, custom upgrade looper, etc). Chris O’Brien blogged a nice series on the basics of this upgrade mechanism. Basicly, the upgrade code will process some new CAML elements (eg. Customxxx) One of these elements however is pretty powerfull, aspecially in migration and heavy upgrade situations, but at the same time this element is pretty unknown as well. I’m talking about the MapFile.
As you can see, the msdn page does not really tell much. Thanks to Reflectorand SQL Manager however we get a pretty good idea what it does. So what is its purpose? The MapFile element will update the internal link of provisioned, uncustomized (thus, still ghosted) files in your SharePoint libraries from one location in your 14 Hive to another.
The element is quite simple to use:
<Mapfile FromPath=string ToPath=string />
It’ll find all files that have been provisioned from “FromPath”, and it will update it to “ToPath”. Mind you this will work on a per-site basis. If you have a MapFile element in site collection feature, it’ll only use the rootweb.
To illustrate the power of this element, here are some use cases:
- You have a customized document library with custom form pages, and you want to revert them to the form pages of the original document library.
<MapFile FromPath="Features\MyCustomDocLib\Schema\ViewPage.aspx" ToPath="Global\Forms\ViewPage.aspx" />
- You’ve been using a page layout for some time and in the new version the developers create new features and renamed the page layouts.
<MapFile FromPath="Features\MyPageLayouts\PageLayouts\OverviewPageLayout.aspx" ToPath="Features\MyPageLayoutsV2\PageLayouts\NewOverviewPageLayout.aspx" />
- An external solution has been retracted making some pages/files/document libraries unavailable You want to re-enable them without deleting and recreating them, as there is a lot of content and versioning on them.
<MapFile FromPath="Features\3rdPartyFeature\Pages\Page1.aspx" ToPath="Features\InHouse\Pages\Page1.aspx" />
So that’s for MapFile. See you next time!
Ps: when using feature upgrading don’t forget it’ll only work with solution upgrading.

























