PnP stands for Practices and Patterns which is a community driven open source project, where Microsoft and community members have created an implementation pattern for Office 365 and SharePoint on-premises. One of the branches of the PnP development is PnP Core CSOM Library.

PnP Core Library provides CSOM extension methods for SharePoint 2016 add-in model development. Official documentation can be accessed here. PnP Core Library increases the productivity of the developers by abstracting the complex operations. In this article, we will see how to set up PnP core library remotely and work with SharePoint 2016, using a Console Application.

In order to work with PnP Core library, we first have to install NuGet Package Manager, which is explained in this article.

Once the PnP Core Library is added, we can kick off the implementation using a Console application.

Project structure

Create a Console Application and add the references, given below-

Scope of the article will be to perform the operations, given below, using PnP Core CSOM Library-

The code blocks for each operation will be given with a sub heading ‘Full Code’. It can be interchangeably placed within the Main function to test the working.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.SharePoint.Client;
  7. using OfficeDevPnP.Core;
  8. namespace OfficeDevPnP {
  9. class SP2016 {
  10. static void Main(string[] args) {
  11. //Place Internal Implementation code here
  12. }
  13. }
  14. }
Internal Implementation

Let’s explore each operation.

Create Sub site

Delete Web

Let’s see, how to apply PnP extension method to delete the Web.

Retrieve all sites

Now, let’s see, how to retrieve all the sites, using PnP Extension method.

Summary

You can copy and paste the ‘Full Code’ fragment into the Main() of the Console Application of the project structure, given at the starting of the article to test it at your end. Thus, we have seen, how to perform SharePoint sub-site operations on remote basis, using PnP Core Library. In this method, you don’t have to get into the Server where SharePoint 2016 is installed, because it enables us to work on a remote basis.