So your client would like for you to provide a custom branded master page and would also like it delivered as a feature at the site collection level. No Problem! Before developing the solution you need to create the new master page. That means you need to fire-up SharePoint Designer 2010 and go through the process of creating a custom branded master page along with the files and folders required. How do you do that? Well, make a copy of the v4.master and rename it to a name of your choice. In my case, I named it jtwebnet.master like you see here. You can do this with either a Team Site template or the one I used for my Site Collection (root), the Publishing template.



Then, under the Style Library I created a folder called "jtwebnet" and under jtwebnet another folder called "images". I also created a new CSS styles sheet called "jtwebnet.css" under the jtwebnet folder. Here is a screenshot:



Work your magic ( on your development environment) and make the adjustments and tweaks required, and when your happy with the final look create a folder on your desktop and save the master page, images, and CSS file. I did it this way but you can choose to do it differently so long as you have access to those files when it comes time to adding them to your solution.


Oh, about that solution. Now lets fire-up Visual Studio 2010 and create a new project, using the "Empty SharePoint Project" template. I named my project "jtwebnetBrandSolution"


You can point the project to the sandbox or the farm and you can create this solution in either SharePoint Foundation or SharePoint Server. It will work either way because you are deploying all the required branding files using template files and Modules and the solution is not picking up any server dependencies. Take a look at the folder structure of solution.




Double click main.feature and make the following chages. Scope to Site!



Double click the Main.EventReceiver.cs file and add the following event handlers. Remember Syncronous/Asyncronous? Syncronous provides a blocking action to a running thread and only continues when an another action completes. Asyncronous provides action after-the-fact using another thread (two threads) for a method, or somethig like that. Ok, I'm getting off track and I'm sure I'll get mail on this one.

FeatureActivated
FreatureDeactivating

Now let's add two Modules shall we, I named them "MasterPageGallery" and the other one "Style Library". Right-click the MasterPageGallery folder and add existing file and add the master page (remember where you saved your files?).



Open the elements.xml file and add the following markup. You must add the following attributes and properties in order to correctly deploy the master page. This is the SharePoint beast! You want to know the difference between typical ASP.Net web developing and SharePoint? Well, aside from all of the many differnt methodologies and the difficulty in debugging your solutions, you need to learn Collaborative Application Markup Language (CAML).



We don't have to modify the elements.xml file under the Style Library Module so you can just add the existing files such as the .CSS file and images. Yes, right click the Style Library and add the .CSS file and right click the images folder and add existing files, IMAGES!

Before Deployment

Deploy the solution and then navigate to the home page.

After Solution Deployment


Now go to site actions and click site settings. Under Site Administration click Site Collection Features and deactivate the feature.




Now you can deploy this solution to any farm and better yet, an easier way to migrate your solution to the next version, we hope, right?

References: Microsoft SharePoint 2010 by Ted Pattison, Andrew Connell, Scot Hillier and David Man (Mar 8, 2011)