When using SPMeta 2, the first starting point is to read the two links below to find out more about what is SPMeta2:
Then the next step is to Learn the basics
Finally lets get cracking on how to implement and use SPMeta2. You can follow this link Get started from scratch or alternately follow my instructions below.
Step 1: Installing NuGet
The pre-requisite is to ensure that you have NuGet installed for your Visual Studio (VS). NuGet is available for the following clients:
- Visual Studio 2013: Visual Studio Extension Gallery
- Visual Studio 2010 and 2012: Visual Studio Extension Gallery
- Visual Studio 2015: Visual Studio Extension Gallery
- Command-Line Utility: Direct Download
- Follow my blog here on how to install NuGet in VS.
Step 2: Setting up SPMeta2
- Go to SubPointSolutions homepage on Github and download the latest SPMeat2. NOTE: Check the release note first to ensure that you are downloading the latest stable version and NOT the beta (still have bugs) version.
- Extract the zip file.
- One you have SPMeta2 solutions open (SPMeta2.sln) in VS 2013, you can either build it with Visual Studio 2013 or use “build.ps1″ script located in /SPMeta2/SPMeta2.Build folder. NOTE: Trying to open the solution in previous version of VS lower than 2013 will fail in opening a project such as SPMeta2\SPMeta2.Containers.O365\SPMeta2.Containers.AppContainer\SPMeta2.Containers.AppContainer.csproj
Step 3: Create a CSOM Solution for SharePoint 2013
- Create a new Console Application in VS 2013
- In Console App, right click “References”->Manage NuGet Packages
- Search and install SPMeta2.CSOM.Foundation package
- Search and install SPMeta2.SSOM.Foundation package
- Add reference Microsoft.SharePoint.Client (v15)
- Add reference Microsoft.SharePoint.Client.Runtime (v15)
Step 4: Setup your definitions, model and provision service
There are a few outtanding things we need to complete – create definitions, setup relationships between them and, finally, push the model to the SharePoint site.
Include the following CSOM code below in your console application changing the ‘siteUrl’, run it and enjoy the outcome.
Alternatively if you want to instead deploy using SSOM code, then all the code is still the same as bove, but the only difference is that you need to add the reference, replace CSOM code with SSOM code below
// deploy the model to the SharePoint site over CSOM
var ssomProvisionService = new SSOMProvisionService();
See other sample scenarios of SPMeta2 in action.
Have a Closer Look
- Definitions concept
- Models concept
- SharePoint Foundation provision
- SharePoint Standard provision
- Useful utils