Intro

Recently I have found a nice library that made my life easier. According to authors it is the most comprehensive, enterprise-ready framework for provisioning SharePoint artifacts on SharePoint 2010, 2013 and O365. SPMeta2 is a code-first provision library supporting the provision of more than 120 artifacts in robust, highly repeatable and testable way while leveraging either one of the CSOM or SSOM SharePoint runtimes.

The library has the github repo with a documentation and lots of examples. The library is distributed via NuGet

Authors claim that SPMeta2 fully replaces XML allowing you to focus on writing clean, unified, reliable and reusable code.

I have tried to deploy a few lists and almost everything have been handled by SPMeta2.

Code

Here is the small example of what can be done:

    var model = SPMeta2Model.NewWebModel();
    model.AddList(new ListDefinition
    {
        Title = "States",
        CustomUrl = "States",
        Description = "The list of Australian states",
        TemplateType = BuiltInListTemplateTypeId.GenericList,
        ContentTypesEnabled = false,
        EnableAttachments = false,
        NoCrawl = true
    }, l => l
        .AddListItems(new[] {
            new ListItemDefinition { Title = "NSW" },
            new ListItemDefinition { Title = "VIC" },
            new ListItemDefinition { Title = "TAS" },
            new ListItemDefinition { Title = "SA" },
            new ListItemDefinition { Title = "QLD" },
            new ListItemDefinition { Title = "NT" },
            new ListItemDefinition { Title = "ACT" },
        }));

    var ssomProvisionService = new SSOMProvisionService(); // It is possible to use CSOM here
    ssomProvisionService.DeployWebModel(web, model);

This piece of code will create a list of Australian states on a target Web. The good thing is you can use the same model for SharePoint 2010, SharePoint 2013 and SharePoint Online.

I have migrated a bunch of old XML definitions to SPMeta2 models and now they work for both Onprem and Online.

Summary

There are still some tasks where users have to fall-back to the native SharePoint object model. In any case, I hope the development of this awesome lib will be continued.


;