Building the project
Make a clone of the repository, navigate to the
build folder in the repository and run
This will restore all references and copy the required files to the correct location on your computer.
Notice that we refer to the nuget package of the PnP.Framework project. As this is rebuilt every night you will receive a new version of the PnP.Framework package every day.
If you run on Windows both the .NET Framework and the .NET Core version will be build and installed.
If you run on MacOS or Linux only the .NET Core version will be build and installed.
Unlike the older repository for the legacy version of PowerShell for Windows you do not need to have local clone of the PnP Framework repository anymore (we changed the PnP Sites Core library used under the hood to the PnP Framework repository, see for more info about that library here: https://github.com/pnp/pnpframework).
In the repository you'll find the following folder structure
- build - documentation - pages - resources - samples - src/ALC /Commands /Resources /Tests
The build folder contains scripts used to build the project, build the Helpfile, etc. While debugging locally the
Build-Debug.ps1 script is the script to use to build the project and copy the correct files to the correct location on your machine. The other build scripts are used in GitHub actions to automate the nightly builds etc.
The documentation folder contains the markdown files all describing every single cmdlet available. If you create a new cmdlet we require you to also provide a documentation file. Notice that the documentation files require a front-matters yaml header as specified in the other files. Updated accordingly.
The pages folder contains the structure which is published to https://pnp.github.io/powershell. We automatically copy the cmdlet documentation in there at build time, but you can create PRs on the 'articles' folder if you want.
The resources folder contains an XML file which is copied into the output folder of the build. This file defines how PowerShell should parse and render the objects shown as output from the PnP PowerShell cmdlets
Due to possible conflicts with already loaded assemblies in PowerShell we create an Assembly Load Context for a specific assembly. See https://docs.microsoft.com/en-us/dotnet/core/dependency-loading/understanding-assemblyloadcontext for more information about ALCs.
This is the main location of all the cmdlet code.
Any resources used by cmdlets go into this folder
This is where the the unit/integration tests reside. See Running test for more information.
Running against a local copy of the PnP Framework
If your code changes require changes to the PnP Framework you might want to use a local version of the PnP Framework which you modified. In order to do this you will need to have both the PnP.PowerShell repository (https://github.com/pnp/powershell) and the PnP.Framework repository (https://github.com/pnp/pnpframework) locally on your computer. Make sure that both repositories are located at the same folder level. E.g.:
Now, build the PnP Framework by navigating to the
build folder in the
pnpframework folder and run
Build-Debug.ps1. This will compile the PnP Framework.
Next, navigate to the
build folder of the
powershell folder and run
Build-Debug.ps1 -LocalPnPFramework. This will compile PnP PowerShell and refer to the -locally- compiled version of the PnP Framework. If you do not specify the
-LocalPnPFramework switch it will refer to the latest nightly build available on NuGet.org instead.