GovUK.Dfe.CoreLibs.SharePoint 0.0.2

Prefix Reserved
dotnet add package GovUK.Dfe.CoreLibs.SharePoint --version 0.0.2
                    
NuGet\Install-Package GovUK.Dfe.CoreLibs.SharePoint -Version 0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GovUK.Dfe.CoreLibs.SharePoint" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GovUK.Dfe.CoreLibs.SharePoint" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="GovUK.Dfe.CoreLibs.SharePoint" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GovUK.Dfe.CoreLibs.SharePoint --version 0.0.2
                    
#r "nuget: GovUK.Dfe.CoreLibs.SharePoint, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GovUK.Dfe.CoreLibs.SharePoint@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GovUK.Dfe.CoreLibs.SharePoint&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=GovUK.Dfe.CoreLibs.SharePoint&version=0.0.2
                    
Install as a Cake Tool

GovUK.Dfe.CoreLibs.SharePoint

A Microsoft Graph-based library for accessing SharePoint document libraries from .NET services using app-only (client credentials) authentication. Supports creating folders, listing/uploading/downloading/deleting files.

Features

  • App-only authentication via client secret or certificate (Azure.Identity)
  • Folder creation with automatic parent folder creation
  • List files in a folder (non-recursive)
  • Upload and download files in document libraries
  • Delete files in document libraries
  • Dependency injection via AddSharePointServices
  • Configuration via appsettings.json or explicit options

Required Graph permissions

Register an Entra ID application and grant the application permission:

  • Sites.ReadWrite.All (admin consent required)

Quick start

1. Installation

dotnet add package GovUK.Dfe.CoreLibs.SharePoint

2. Configuration

Add SharePoint configuration to appsettings.json:

{
  "SharePoint": {
    "TenantId": "your-tenant-id",
    "ClientId": "your-client-id",
    "ClientSecret": "your-client-secret",
    "SiteHostname": "contoso.sharepoint.com",
    "SitePath": "/sites/MySite"
  }
}

Alternatively, set SiteId instead of SiteHostname/SitePath.

Certificate-based auth (instead of ClientSecret):

{
  "SharePoint": {
    "TenantId": "your-tenant-id",
    "ClientId": "your-client-id",
    "CertificatePath": "C:\\certs\\app.pfx",
    "CertificatePassword": "optional-password",
    "SiteId": "contoso.sharepoint.com,guid,guid"
  }
}

3. Register services

services.AddSharePointServices(configuration);

// Or with explicit options
services.AddSharePointServices(new SharePointOptions
{
    TenantId = "...",
    ClientId = "...",
    ClientSecret = "...",
    SiteHostname = "contoso.sharepoint.com",
    SitePath = "/sites/MySite"
});

4. Use the service

Paths start with the document library name, then the folder path within that library:

public class DocumentService(ISharePointService sharePoint)
{
    public async Task SaveReportAsync(Stream content, CancellationToken ct)
    {
        await sharePoint.CreateFolderAsync("Documents/reports/2024", ct);
        await sharePoint.UploadFileAsync("Documents/reports/2024", "summary.pdf", content, ct);

        var files = await sharePoint.ListFilesAsync("Documents/reports/2024", ct);
        await using var download = await sharePoint.DownloadFileAsync("Documents/reports/2024", "summary.pdf", ct);
        await sharePoint.DeleteFileAsync("Documents/reports/2024", "summary.pdf", ct);
    }
}

API overview

Method Description
CreateFolderAsync(folderPath) Creates the folder and any missing parents
ListFilesAsync(folderPath) Lists files in the folder (not subfolders)
UploadFileAsync(folderPath, fileName, content) Uploads or overwrites a file
DownloadFileAsync(folderPath, fileName) Downloads file content as a stream
DeleteFileAsync(folderPath, fileName) Deletes a file from the folder

Path format: {LibraryName}/{folder/...} (e.g. Documents/reports/2024). Use just the library name (e.g. Documents) for the library root when listing, uploading, downloading, or deleting. CreateFolderAsync requires at least one folder under the library.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 108 8/18/2026
0.0.2-prerelease.72 76 8/18/2026
0.0.2-prerelease.61 71 8/13/2026
0.0.2-prerelease.51 64 8/13/2026
0.0.2-prerelease.32 71 8/10/2026
0.0.2-prerelease.25 69 8/10/2026
0.0.2-prerelease.20 69 8/10/2026
0.0.2-prerelease.17 69 8/7/2026
0.0.1 271 7/21/2026
0.0.1-prerelease.238 74 7/21/2026
0.0.1-prerelease.232 68 7/17/2026
0.0.1-prerelease.228 69 7/17/2026