Parse, build, and normalize Package URLs (purl) per ECMA-427. Handles strings like pkg:nuget/[email protected].
Install
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard |
README
packageurl-dotnet
A .NET parser for Package URLs (ECMA-427). Handles strings like pkg:nuget/[email protected] -- parses them apart, builds them from components, gives you a canonical form back.
Targets .NET Standard 2.0, so it works anywhere from .NET Framework 4.6.1 through .NET 10+.
Install
dotnet add package packageurl-dotnet
Or in your project file:
<PackageReference Include="packageurl-dotnet" Version="2.0.0" />
Usage
Parse a PURL string:
var purl = new PackageURL("pkg:nuget/[email protected]");
Console.WriteLine(purl.Type); // nuget
Console.WriteLine(purl.Name); // Newtonsoft.Json
Console.WriteLine(purl.Version); // 13.0.1
Build one from parts:
var purl = new PackageURL(
type: "maven",
@namespace: "org.apache.commons",
name: "commons-lang3",
version: "3.14.0",
qualifiers: null,
subpath: null);
Console.WriteLine(purl.ToString());
// pkg:maven/org.apache.commons/[email protected]
There's also a two-argument shorthand if you only need type and name:
var purl = new PackageURL("npm", "lodash");
Build from source
Requires .NET SDK 10+.
dotnet pack -c Release
dotnet test -c Release ./tests
Or open PackageUrl.slnx in Visual Studio 2022+ and run tests from Test Explorer.
License
Changes from Previous Version
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.