共用方式為


Introducing Office 365 Developer PnP core component as nuget package

We are happy to announce that reusable remote PnP Core component from the Office 365 Developer Patterns and Practices (PnP) guidance has been released as a nuget package. This means that you can easily start using the latest released version of the component in your customizations.

There are two difference nuget packages released, one towards the Office 365 and one for on-premises, due the differences in the CSOM package.

image

We will keep on updating these nuget packages based on your input, but at least in monthly basis as part of the master merge operations for PnP guidance.

What is PnP Core component?

PnP Core component is reusable remote component for encapsulating code which is commonly used with app model implementations. It is designed for provider hosted platform or to be used directly in .NET code, for example from web job in Azure or where ever needed. PnP Core component is created based on community contributions and is evolving pretty fast. Right now there are still some visible differences on the method signatures, but we are gradually moving the component to more consistent behaviour.

When you have added reference to PnP Core component, most of the capabilities are provided as extension methods to native CSOM objects. Here’s few examples of core component usage. Below code samples are assuming that you have instance in web object, which is type of Microsoft.SharePoint.Client.Web.

  • Create a sub site – web.CreateSite(“sub”, “rul”, "Description", “STS#0”, 1033);
  • Set theme to site - web.SetThemeToWeb("SPC");
  • Add document library – web.CreateDocumentLibrary("Specifications");
  • Create a content type - web.CreateContentType(“ContosoDoc”, “0x010100439c9788ea394e74941ded29b22f9b6b”, "Contoso Content Types");
  • Create a site column – web.CreateField(“439c9788-ea39-4e74-941d-ed29b22f9b6b”, "ContosoFieldText", FieldType.Text, "Contoso Field Text", "Contoso Fields");
  • Add site column to content type - web.AddFieldToContentTypeByName(“ContosoDoc”, “439c9788-ea39-4e74-941d-ed29b22f9b6b”)

There are many other supported methods, which will increase the productivity of the developers. All scenarios in the PnP guidance are showing difference capabilities of the Core component usage or you can simply download the core component source code to see all the details and the implementations of individual operations.

All changes in the core component are introduced in away that we provide backward compatibility with previous versions. We mark possible changes in methods directly in the code as Obsolete, but code will still work like with previous releases.

Here’s and example how the obsolete methods are indicated when we evolve the component. This code will still work until further notice, but you can see the recommended change in the warning descriptions. Right now we do not introduce breaking changes, but we are anticipating bigger refactoring at some point when resources are permitting that. We will communicate that clearly in the Patterns and Practices communications in timely fashion.

clip_image001

Using PnP Core component Nuget package

In this case-by-case picture set, we will create a new console application and will add Nuget package association to the project to get easily started with the development.

1. Let’s start by creating a new console application

image

2. Right click the project and choose “Manage NuGet Packages…

image

3. Search for “OfficeDev” and you will find two different packages, one for Office 365 and one for on-premises

image

4. Click Install and all the needed components are added to your applications. You will also need to accept the EULAs for some of them.

imageimage

5. Installation is completed when package is showing “Installed” or indicating that in the UI

image

6. Check the references of the solution and notice that needed client side components have been added.

image

7. Notice also that the TokenHelper.cs and SharePointContext.cs is available for you

image

8. Start developing whatever is needed… as simple as that.

 

Show me how it’s done

Here’s a short video showing the process in practice.

 

How can I give feedback?

Please join us to the Office 365 Technical Yammer Network and give us feedback and suggestions using the Office 365 Developer Patterns and Practices Yammer group at https://aka.ms/OfficeDevPnPYammer. Your feedback is more than welcome, so do not hesitate to give us comments or suggestions for improvements.

Office 365 Developer Patterns and Practices

Office365PnPLogoRed_thumb1Techniques showed in this blog post are part of the OfficeDevPnP.Core component in the Office 365 Developer Patterns and Practices guidance, which contains more than 90 samples and solutions demonstrating different patterns and practices related on the app model development together with additional documentation related on the app model techniques.

Check the details directly from the GitHub project at https://aka.ms/OfficeDevPnP. Please join us on sharing patterns and practices for the community for the benefit of the community.

“From the community for the community” – “Sharing is caring”

Comments

  • Anonymous
    November 17, 2014
    Great news Vesa. Keep up the awesome work. Tob.

  • Anonymous
    November 18, 2014
    Really cool stuff Vesa, JT, CJ, and Sonya keep it coming. Its all about productivity baby :-)

  • Anonymous
    November 18, 2014
    Nice Work. --Rjesh.

  • Anonymous
    November 20, 2014
    Great, efforts are taking shape quickly. I will get in touch with you for contribution in PnP.

  • Anonymous
    November 21, 2014
    Great news, and great work Vesa! This is really great, and will help all fellow SharePointers! Look forward to give it a go

  • Anonymous
    December 05, 2014
    This is great. Thank you so much Vesa :)

  • Anonymous
    March 06, 2015
    Thanks for making things simple......