nuget-to-json: fix missing tool packages

After dotnet 9.0.1->9.0.2, when a package is restored with 'tool
install', .nupkg.metadata no longer contains the field:

    "source": null

It still contains "contentHash", so we return a dummy source name in
that case.

Fixes: 383ceb66d1
This commit is contained in:
David McFarland
2025-03-11 16:15:49 -03:00
parent 383ceb66d1
commit 42a751ad87
@@ -62,7 +62,8 @@ done
fi
# packages in the nix store should have an empty metadata file
used_source="$(jq -r 'if has("source") then .source else "" end' "$version"/.nupkg.metadata)"
# packages installed with 'dotnet tool' may be missing 'source'
used_source="$(jq -r 'if has("source") then .source elif has("contentHash") then "__unknown" else "" end' "$version"/.nupkg.metadata)"
found=false
if [[ -z "$used_source" || -d "$used_source" ]]; then