Kreisverkehr.NetUpnp 0.1.1

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

NetUpnp

NetUpnp is a small .NET library for discovering and reading Universal Plug and Play (UPnP) devices.

This project is a work in progress. The API, behavior, and package contents may change without notice. It is not yet recommended for production use.

Requirements

  • .NET 10
  • A network interface that can reach the UPnP devices being discovered

Installation

dotnet add package Kreisverkehr.NetUpnp

Quick start

Register NetUpnp with the Microsoft dependency injection container and enumerate discovered devices as typed XML descriptions:

using Kreisverkehr.NetUpnp;
using Kreisverkehr.NetUpnp.Model;
using Microsoft.Extensions.DependencyInjection;

IServiceProvider services = new ServiceCollection()
    .AddUpnp()
    .BuildServiceProvider();

IUpnpClient<UpnpDescription> upnpClient = services.GetRequiredService<IUpnpClient<UpnpDescription>>();

await foreach ((Uri location, UpnpDescription description) in upnpClient.DiscoverDevicesAsync("ssdp:all"))
{
    Console.WriteLine($"{description.Device.FriendlyName} ({description.Device.DeviceType})");
    Console.WriteLine($"Description at {location}");
}

DiscoverDevicesAsync uses SSDP discovery and yields the service description location together with the parsed description. The raw IUpnpClient interface also exposes a XDocument-based flow when you want to inspect the untyped XML. RunDiscoverDevicesAsync remains available for event-driven discovery through the DeviceDiscovered event.

Custom descriptions

UPnP devices can expose vendor-specific XML elements. Derive your own description and device model classes from UpnpDescription and UpnpDevice, then resolve the generic IUpnpClient<TDescription> for the specific type you want to deserialize:

using Kreisverkehr.NetUpnp;
using Microsoft.Extensions.DependencyInjection;

IServiceProvider services = new ServiceCollection()
    .AddUpnp()
    .BuildServiceProvider();

IUpnpClient<MyUpnpDescription> upnpClient = services.GetRequiredService<IUpnpClient<MyUpnpDescription>>();

await foreach ((Uri location, MyUpnpDescription description) in upnpClient.DiscoverDevicesAsync("urn:example:device:MyDevice:1"))
{
    MyUpnpDevice device = (MyUpnpDevice)description.Device;
    Console.WriteLine($"{device.FriendlyName}: {device.CustomValue}");
    Console.WriteLine($"Description at {location}");
}

The custom description and device types should use XmlSerializer attributes for their XML elements. See the sample in Samples/CustomizeUpnpDescription.cs.

Samples

The runnable examples are documented in Samples/README.md.

License

NetUpnp is available under the MIT license. See 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
0.1.1 79 10/3/2026
0.1.0 87 9/25/2026