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
<PackageReference Include="GovUK.Dfe.CoreLibs.SharePoint" Version="0.0.2" />
<PackageVersion Include="GovUK.Dfe.CoreLibs.SharePoint" Version="0.0.2" />
<PackageReference Include="GovUK.Dfe.CoreLibs.SharePoint" />
paket add GovUK.Dfe.CoreLibs.SharePoint --version 0.0.2
#r "nuget: GovUK.Dfe.CoreLibs.SharePoint, 0.0.2"
#:package GovUK.Dfe.CoreLibs.SharePoint@0.0.2
#addin nuget:?package=GovUK.Dfe.CoreLibs.SharePoint&version=0.0.2
#tool nuget:?package=GovUK.Dfe.CoreLibs.SharePoint&version=0.0.2
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.jsonor 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 | Versions 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. |
-
net8.0
- Azure.Identity (>= 1.17.0)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Graph (>= 5.105.0)
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 |