SPDX support for .Net applications
$ dotnet add package Tethys.SPDX.ExpressionParserThe Software Package Data Exchange (SPDX) is an open standard for describing a software bill of material. SPDX focuses especially on licensing and copyright information.
License and copyright scanners like FOSSology for example use this standard to provide their scan results.
Having a format to describe all the different scenarios of license findings, license relations, and copyright findings is not trivial, so SPDX can get quite complex.
The libraries in this project support two tasks:
Please note that due to the complexity of the SPDX standard not all possible SPDX files can be parsed. But the libraries are open source, so feel free to enhance them.
The following packages are available on NuGet:
This library has been influenced by the following GitHub projects:
System.Text.Json instead of Newtonsoft.JsonThere an ongoing discussion whether to use System.Text.Json instead of Newtonsoft.Json.
Well, moving from Newtonsoft.Json to System.Text.Json is not straightforward and costs
quite some effort. SPDX JSON reading and writing is based on many Newtonsoft JsonConverters
and at the moment there is no plan to change this. If someone wants to take the challenge, well,
go ahead and do a pull request.
Current status:
The following packages do not use any JSON support:
The following packages use System.Text.Json:
The following packages use Newtonsoft.Json:
See https://spdx.org/licenses/ for more details on SPDX, the software package data exchange format, the SPDX license identifiers and matching guidelines.
The Software Package Data Exchange (SPDX) Specification https://spdx.github.io/spdx-spec/
XML data of all SPDX licenses:
https://github.com/spdx/license-list-XML
The SPDX license information is not part of the libraries, you have to download it from SPDX License List and place it in a local folder.
A minimal code snippet looks like this
var knownLicenseManager = new KnownLicenseManager();
knownLicenseManager.LoadSpdxSourceFiles(...SPDX license files...);
knownLicenseManager.LoadSpdxExceptionFiles(...SPDX license exception files...);
var reader = new RdfParser(knownLicenseManager);
var spdxDoc = reader.ReadFromFile(...SPDX file...);
...
Just run the demo application
dotnet run --project .\SpdxParserDemo\SpdxParserDemo.csproj .\TestData\yaml-0.1.0.zip.spdx2.rdf.xml
or
dotnet run --project .\SpdxParserDemo\SpdxParserDemo.csproj .\TestData\SPDXJSONExample-v2.3.spdx.json
Just use the basic dotnet command:
dotnet build
Copyright (c) 2019-2025 T. Graf. Tethys.SPDX is licensed under the Apache License, Version 2.0.