diff --git a/console/console.csproj b/console/console.csproj
index 5cbc172..9309551 100644
--- a/console/console.csproj
+++ b/console/console.csproj
@@ -9,6 +9,7 @@
+
diff --git a/deps.json b/deps.json
index 126157e..af5b430 100644
--- a/deps.json
+++ b/deps.json
@@ -8,5 +8,11 @@
"pname": "Groomgy.HelloWorldDependencyLibrary",
"version": "1.16.1",
"hash": "sha256-bReNmXls62mIi/13iOq55RutIfyddDDVpyqbIkSBBno="
+ },
+ {
+ "pname": "Humanizer.Core",
+ "version": "2.8.26",
+ "hash": "sha256-VVtCdloK3vz9bPq0hqHaGVcWu3IGbtJqwJjo6kVoHe0=",
+ "url": "https://pkgs.dev.azure.com/unicornde/_packaging/ed5a6385-7bf5-49ae-8472-0d53404feafe/nuget/v3/flat2/humanizer.core/2.8.26/humanizer.core.2.8.26.nupkg"
}
]
diff --git a/flake.nix b/flake.nix
index 5accef8..8ec5705 100644
--- a/flake.nix
+++ b/flake.nix
@@ -64,6 +64,7 @@
packages = [
just
nuget-to-json
+ azure-artifacts-credprovider
(
with dotnetCorePackages;
combinePackages [
diff --git a/justfile b/justfile
index c0e4244..7ed7f33 100644
--- a/justfile
+++ b/justfile
@@ -1,4 +1,8 @@
+setup-nuget nuget-pat:
+ export NUGET_PAT="{{nuget-pat}}"
+ wget -qO- https://aka.ms/install-artifacts-credprovider.sh | bash
+
run project:
dotnet restore --packages out
- nuget-to-json out > deps.json
+ ./nuget-to-json out > deps.json
nix run .#{{project}}
diff --git a/nuget-to-json b/nuget-to-json
new file mode 100755
index 0000000..b5329f2
--- /dev/null
+++ b/nuget-to-json
@@ -0,0 +1,122 @@
+#!/nix/store/ciarnmsx8lvsrmdbjddpmx0pqjrm8imb-bash-5.3p3/bin/bash
+# shellcheck shell=bash
+
+set -euo pipefail
+shopt -s nullglob
+
+export SSL_CERT_FILE=/nix/store/6jsh5hyyli9ddac6dqxx07a68jzllkqb-nss-cacert-3.115/etc/ssl/certs/ca-bundle.crt
+export PATH="/nix/store/rqn7v98b071xg19iyrz3qzlby8nwmqh3-nix-2.31.2/bin:/nix/store/xs8scz9w9jp4hpqycx3n3bah5y07ymgj-coreutils-9.8/bin:/nix/store/frzsv47z1mcyrp941zab08mx6kardizi-jq-1.8.1-bin/bin:/nix/store/69j5n7qzjlphqpgsx4bbbp6zcklm7cih-xmlstarlet-1.6.1/bin:/nix/store/xvh4bi0cc2cw18lpn6ax9m4zwnn1s9lj-curl-8.16.0-bin/bin:/nix/store/22r4s6lqhl43jkazn51f3c18qwk894g4-gnugrep-3.12/bin:/nix/store/8c4l9cqqj7pixqlmljx5d495pfpw8pys-gawk-5.3.2/bin:$PATH"
+# used for glob ordering of package names
+export LC_ALL=C
+
+if [ $# -eq 0 ]; then
+ >&2 echo "Usage: $0 [path to a file with a list of excluded packages] > deps.json"
+ exit 1
+fi
+
+pkgs=$1
+tmp=$(realpath "$(mktemp -td nuget-to-json.XXXXXX)")
+trap 'rm -r "$tmp"' EXIT
+
+excluded_list=$(realpath "${2:-/dev/null}")
+
+export DOTNET_NOLOGO=1
+export DOTNET_CLI_TELEMETRY_OPTOUT=1
+
+mapfile -t sources < <(dotnet nuget list source --format short | awk '/^E / { print $2 }')
+wait "$!"
+
+declare -a remote_sources
+declare -A base_addresses
+
+for index in "${sources[@]}"; do
+ if [[ -d "$index" ]]; then
+ continue
+ fi
+
+ remote_sources+=("$index")
+
+ echo "fetching index: $index" >&2
+
+ index_response=$(
+ if [[ "$index" =~ .*dev\.azure\.com.* ]] && [ -n "$NUGET_PAT" ]; then
+ curl --anyauth -u "user:$NUGET_PAT" --netrc-optional --compressed -fsSL "$index"
+ else
+ curl --netrc-optional --compressed -fsSL "$index"
+ fi
+ )
+ base_address=$(
+ echo "$index_response" | jq -r '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"'
+ )
+ if [[ ! "$base_address" == */ ]]; then
+ base_address="$base_address/"
+ fi
+ base_addresses[$index]="$base_address"
+done
+
+(
+ echo '['
+
+ first=true
+ cd "$pkgs"
+ for package in *; do
+ [[ -d "$package" ]] || continue
+ cd "$package"
+ for version in *; do
+ echo "fetching package: $package $version" >&2
+
+ id=$(xmlstarlet sel -t -v /_:package/_:metadata/_:id "$version"/*.nuspec)
+
+ if grep -qxF "$id.$version.nupkg" "$excluded_list"; then
+ continue
+ fi
+
+ # packages in the nix store should have an empty metadata file
+ # 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)"
+ echo "used source: $used_source" >&2
+
+ found=false
+
+ if [[ -z "$used_source" || -d "$used_source" ]]; then
+ continue
+ fi
+
+ for source in "${remote_sources[@]}"; do
+ echo "trying source: $source" >&2
+
+ url="${base_addresses[$source]}$package/$version/$package.$version.nupkg"
+ echo "full url: $url" >&2
+
+ if [[ "$source" == "$used_source" ]]; then
+ hash="$(nix-hash --type sha256 --flat --sri "$version/$package.$version".nupkg)"
+ echo "hash: $hash" >&2
+ found=true
+ break
+ fi
+ done
+
+ if [[ $found = false ]]; then
+ echo "couldn't find $package $version" >&2
+ exit 1
+ fi
+
+ if [[ $first = false ]]; then
+ echo ' , {'
+ else
+ echo ' {'
+ fi
+ echo " \"pname\": \"$id\""
+ echo " , \"version\": \"$version\""
+ echo " , \"hash\": \"$hash\""
+ if [[ "$source" != https://api.nuget.org/v3/index.json ]]; then
+ echo " , \"url\": \"$url\""
+ fi
+ echo ' }'
+ first=false
+ done
+ cd ..
+ done
+
+ echo ']'
+) | jq .
diff --git a/nuget.config b/nuget.config
new file mode 100644
index 0000000..2a156db
--- /dev/null
+++ b/nuget.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+