Creating publishing sites in SharePoint using Visual Studio – Part 1

I’ve been looking into one of the core missing features from the Visual Studio tools for SharePoint 2010. A really common scenario I have is that you hack together a page layout, master page or site page in SPD (or the browser, for that matter) and then want to package that for deployment or integrate with your development processes in Visual Studio. This should be really simple to do; I do it on every publishing project I do, but it is not intuitive in the new tools.

One way to do this is to package up the library into a WSP, and then import that into a Visual Studio project. This isn’t ideal since it brings across a large amount of stuff you don’t need.

Another option might be to make use of the SharePoint Explorer in Visual Studio to bring that stuff over. But no dice. The server explorer doesn’t give you any useful interaction with a project.

The end game for this blog post series is to have that scenario played out completely. But in the meantime, how would you do this manually anyway? Becky Bertrum has a good post on this here, and as you can see, it’s a pretty manual process. Some key points are just not intuitive enough.

  1. Creating a module. This is fine, but having to manually update the module address to be “_catalogs/masterpage” is OK for people who previously had to create these by hand. For new developers, this is a pretty unintuitive step.
  2. Creating the page layout / master page. Having to create a text file and then rename it with a new (.aspx or .master) extension is pretty lame.
  3. Giving the page layout an associated publishing content type. While better than the old way [go and grab a query string from a URL on the Site Settings area], it is still too hard to get the content type’s ID via Visual Studio.
  4. Adding SharePoint assets to the page. Now you have to actually work with the page layout and make it do what you want. Again, this is easier said than done. Ideally, you’d be able to drill down in the Explorer to Site Pages, Site Assets and the Master Page gallery, right click and say “add this to my project”.

So, what’s to be done with this state of affairs. Thankfully, the SharePoint Visual Studio tools team bought into the extensibility framework that VS2010 delivers. We can change the behaviour of Visual Studio to do what we want to do.

There are a number of distinct tasks I think would be very cool extensions:

  1. Provide a new item type called “SharePoint Publishing Module”. This will automatically set up the correct paths for the master page gallery.
  2. Provide a new item types called “SharePoint Publishing Page Layout”, “SharePoint Master Page” and “SharePoint Site Page”.
  3. Provide a right click action on Content Types and Fields in the SharePoint Explorer to provide a “Copy ID to clipboard” function.
  4. Provide the ability to drag master pages, page layouts and site pages from the SP Explorer into VS modules.

The rest of this series will provide examples of how to do each of these.

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: