Cross Platform PnP PowerShell Released
After close to more than 2 years or work we finally are ready to release a preview build of PnP PowerShell for PowerShell Core! (Check out the original post)
Why did it take so long?
A few factors came into play here. At the MVP Summit in Redmond in 2018 I already demoed a version of PnP PowerShell running on MacOS. For that we needed to a few things:
- We needed to have the Microsoft Client Object Model for SharePoint library (CSOM) available for .NET Standard or .NET Core
- We needed to port our own helper library, PnP Sites Core, to .NET Standard
- We needed to port PnP PowerShell to .NET Standard
Step 1 was initially done by Bert Jansen (https://twitter.com/o365bert) who in a single weekend managed to recompile the CSOM library for .NET Standard. However, that was a single shot, e.g. nothing that would work for the future. More to that later.
Step 2 was done by both Bert and me. We refactored the project to .NET Standard and tried to compile it. If something didn’t work, we fixed it and went on. It took a bit, but we finally had a compiled version of PnP Sites Core (compiled does not mean 100% working…)
Step 3 was the same type work: take the existing PnP PowerShell code and refactor it just enough so it would compile as a .NET Standard library.
Let’s go in a bit more detail for each of the steps below
CSOM
Microsoft provides the compiled (and signed!) versions of Microsoft.SharePoint.Client assemblies (CSOM). We of course can build our own based on the work that Bert did in step 1 above, but that would not be a sustainable way forward. Ideal would be if Microsoft would provide a .NET Standard version themselves. And it took a while, but finally they did. There is a reason why it took a while:
The CSOM libraries are not coded by hand but they are generated based upon server code. There is a complex pipeline that takes the server code for SharePoint 2013, SharePoint 2016, SharePoint 2019 and SharePoint Online, and converts parts of them into the corresponding CSOM libraries.
This pipeline is a complex beast and adding a new target framework for.NET Standard sounds easier than it is as the code that generates the code needed to be updated too.
Nevertheless, in the end they did it and they included the .NET Standard version in the publicly available NuGet package: https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM/
PnP Sites Core
PnP Sites Core is the .NET Framework library that contains the PnP Provisioning Engine, the PnP Pages Framework and tons of other helper methods that extend the CSOM library. It has grown over the years to be huge, but also complex to maintain. The technology landscape changed and we decided to focus our efforts on a new library, which is using the Graph and REST with an optional fallback to CSOM if needed. We call this the PnP Core SDK (https://github.com/pnp/pnpcore). Nevertheless, PnP PowerShell is depending heavily on the PnP Sites Core library which contains the PnP Provisioning Engine (we have not ported that one yet to the PnP Core SDK).
Instead of making or changes in place of the PnP Sites Core library we made a few changes:
- We will deprate PnP Sites Core in a few months
- We will create a new repository and port the existing PnP Sites Core ot that repository and only for .NET Standard, no more support for the .NET Framework.
- We will only support SharePoint Online with the new port
- We will name the new port: PnP Framework
Maybe this roadmap explains things a bit better:
PnP PowerShell
We needed to port PnP PowerShell to a newer version of .NET so it works cross-platform. This means we had to pick either .NET Standard or .NET Core. We went for .NET Core (and in the future we will move to .NET 5).
For that we created, just like with the PnP Framework, a new repository: https://github.com/pnp/powershell. This repository contains the code for PnP PowerShell compiled for .NET Core 3.1 and .NET Framework 4.6.1. Also here we had to make a few decisions:
- We will deprecate the classic PnP PowerShell in a few months
- We created a new project
- We will only support SharePoint Online
- We will publish the build version a PnP.PowerShell to the PowerShell Gallery
Also here we have a roadmap picture:
Overal changes
We changed a lot behind the scenes in both the PnP Framework and PnP PowerShell. Some changes we had to make because of things missing from the .NET Standard version of CSOM, some changes we made because they were long time overdue. A big changes for instance is the whole authentication story. We now only support OAuth based authentication. And while that sounds complex, it’s not that complex (but I’ll admit, there is a threshold you need to get over…). Fortunately we help you with our AuthenticationManager class which is available in the PnP Framework. It goes beyond the scope of this overview email to talk you through the details though, but you can expect community calls, videos and most likely several blog posts explaining how things have changed.
How to install
Okay, so you read the story and you are ready to give it a try. Well, we release