msbuildnugetnuget-packagenuget-server

License expression for commercial nuget package


I'm uploading a private nuget package to a private nuget repository. The package is commercial (not open source).

The csproj has this:

<PackageLicenseExpression>Commercial</PackageLicenseExpression>

I receive a build warning that the above is not a valid "license expression".

What value do I use?


Solution

  • You need to embed your license file, you can't use the license expression: https://learn.microsoft.com/nuget/reference/msbuild-targets#packing-a-license-expression-or-a-license-file

    <PropertyGroup>
        <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
    </PropertyGroup>
    
    <ItemGroup>
        <None Include="licenses\LICENSE.txt" Pack="true" PackagePath=""/>
    </ItemGroup>
    

    NuGet's license expressions use SPDX identifiers, and I don't see any "generic" commercial license.