Semisoft.CalDAVNet 1.1.4

dotnet add package Semisoft.CalDAVNet --version 1.1.4
                    
NuGet\Install-Package Semisoft.CalDAVNet -Version 1.1.4
                    
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="Semisoft.CalDAVNet" Version="1.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Semisoft.CalDAVNet" Version="1.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Semisoft.CalDAVNet" />
                    
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 Semisoft.CalDAVNet --version 1.1.4
                    
#r "nuget: Semisoft.CalDAVNet, 1.1.4"
                    
#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 Semisoft.CalDAVNet@1.1.4
                    
#: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=Semisoft.CalDAVNet&version=1.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Semisoft.CalDAVNet&version=1.1.4
                    
Install as a Cake Tool

CalDAVNet

NuGet Version License: MIT .NET 10

.NET client library for communicating with CalDAV servers compliant with CalDAV (RFC 4791), WebDAV (RFC 4918), and iCalendar (RFC 5545).


Features

  • Calendars & Events: Discover calendar collections, query events, and perform CRUD operations on .ics resources.
  • Recurring Events: Support for master events (MasterEvent), modified occurrences (RecurrenceExceptions), and date-range expansion (GetOccurrences).
  • WebDAV Sync: Incremental collection synchronization using WebDAV sync tokens (SyncCalendarItemsAsync).
  • ASP.NET Core Integration:
    • AddCalDAVClient registration backed by IHttpClientFactory connection pooling.
    • Multi-user authentication support via ICalDAVClientFactory and scoped ICalDAVCredentialsProvider.
  • Safe Error Handling: Structured response objects with status codes and failure details instead of throwing unhandled exceptions.

Building and Testing

Prerequisites

Build

dotnet build

Run Tests

Unit tests run completely offline and verify XML serialization, model parsing, error handling, and DI registration:

dotnet test

To run integration tests against a live CalDAV server, create a .env file in the CalDAVNet.Tests directory:

CALDAVNET_BASEADDRESS=https://caldav.host.ru/
CALDAVNET_USERNAME=your_username@host.ru
CALDAVNET_PASSWORD=your_app_password

Usage Examples

1. Standalone Client (Without DI)

using System.Net.Http.Headers;
using System.Text;
using CalDAVNet;
using CalDAVNet.Http;

var httpClient = new HttpClient
{
    BaseAddress = new Uri("https://caldav.host.ru/")
};

var auth = Convert.ToBase64String(Encoding.UTF8.GetBytes("login:password"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", auth);

ICalDAVClient client = new CalDAVClient(httpClient);

// Retrieve current principal and calendars
var principalName = await client.GetPrincipalNameAsync();
var principal = await client.GetPrincipalAsync(principalName.PrincipalName!);

var calendars = await client.GetCalendarsAsync(
    principal.Principal!.CalendarHomeSet!, 
    CalDAVPayloads.AllProp());

foreach (var cal in calendars)
{
    Console.WriteLine($"Calendar: {cal.Calendar?.DisplayName} ({cal.Calendar?.Href})");
}

2. ASP.NET Core Integration (Dependency Injection)

Registration in Program.cs:
builder.Services.AddCalDAVClient(options =>
{
    options.SetBaseAddress("https://caldav.host.ru/");
    options.SetCredentials("my_user@host.ru", "app_password");
});
Injecting into a service:
public class MyCalendarService(ICalDAVClient calDavClient)
{
    public async Task<GetCalendarResponse> GetCalendarAsync(string href)
    {
        return await calDavClient.GetCalendarAsync(href, CalDAVPayloads.AllProp());
    }
}

3. Multi-User Applications

When users in your application authenticate with their own separate CalDAV credentials:

// Register server base address in Program.cs:
builder.Services.AddCalDAVClient(options =>
{
    options.SetBaseAddress("https://caldav.host.ru/");
});

// Inject ICalDAVClientFactory into your service:
public class UserService(ICalDAVClientFactory clientFactory)
{
    public async Task SyncUserAsync(string userLogin, string userPassword)
    {
        // Creates an isolated client for this specific user
        // while reusing pooled connections from IHttpClientFactory:
        var client = clientFactory.CreateClient(userLogin, userPassword);

        var events = await client.GetEventsAsync("/calendars/user/events/", CalDAVPayloads.AllProp());
        // ...
    }
}

4. Working with Recurring Events

var response = await client.GetEventAsync("/calendars/user/events/", "meeting.ics");

if (response.IsSuccess && response.Event != null)
{
    var ev = response.Event;

    // Master recurring event (without RECURRENCE-ID)
    Console.WriteLine($"Master summary: {ev.MasterEvent?.Summary}");

    // Modified occurrences / exceptions (with RECURRENCE-ID)
    foreach (var exception in ev.RecurrenceExceptions)
    {
        Console.WriteLine($"Modified occurrence: {exception.Summary} at {exception.Start}");
    }

    // Expand occurrences within a specified date/time range:
    var occurrences = ev.GetOccurrences(DateTime.UtcNow, DateTime.UtcNow.AddDays(7));
    foreach (var occ in occurrences)
    {
        Console.WriteLine($"Occurrence: {occ.Period.StartTime}");
    }
}

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
1.1.4 116 11/9/2026