From 32bb4be4c7a891553c33bbd3ca8b228e09fd5469 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Wed, 30 Nov 2022 18:36:49 -0500 Subject: [PATCH] Add a check to make sure runtime graphs are complete We need to make sure Microsoft.NETCore.App.deps.json has a complete runtime fallback graph. Otherwise, it is possible that .NET will fail to find assets placed in paths based on the RID-fallback graph. For more details, see https://github.com/dotnet/runtime/issues/78563 --- runtime-fallback-graph/test.json | 11 +++++++++++ runtime-fallback-graph/test.sh | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 runtime-fallback-graph/test.json create mode 100755 runtime-fallback-graph/test.sh diff --git a/runtime-fallback-graph/test.json b/runtime-fallback-graph/test.json new file mode 100644 index 0000000..50a3669 --- /dev/null +++ b/runtime-fallback-graph/test.json @@ -0,0 +1,11 @@ +{ + "name": "runtime-fallback-graph", + "enabled": true, + "requiresSdk": false, + "version": "3.1", + "versionSpecific": false, + "type": "bash", + "cleanup": true, + "ignoredRIDs":[ + ] +} diff --git a/runtime-fallback-graph/test.sh b/runtime-fallback-graph/test.sh new file mode 100755 index 0000000..aa61c13 --- /dev/null +++ b/runtime-fallback-graph/test.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Check runtime fallback graphs are present in the shared framework + +set -euo pipefail +set -x + +dotnet_dir="$(../dotnet-directory --home "$1")" +portable_rid="$(../runtime-id --portable)" +non_portable_rid="$(../runtime-id)" + +# print for debugging +find "${dotnet_dir}" -iname Microsoft.NETCore.App.deps.json + +while IFS= read -r -d '' file; do + jq '.runtimes' "$file" + length=$(jq '.runtimes | length' "$file") + if [[ $length == 0 ]]; then + echo "Missing .runtimes section in $file" + exit 1 + fi + # quoting here is a bit strange, but it's basically ".runtimes[\"" "$non_portable_rid" "\"] ..." without spaces + length=$(jq ".runtimes[\"""$non_portable_rid""\"] | length" "$file") + if [[ $length == 0 ]]; then + echo "Missing runtimes[$non_portable_rid] section in $file" + exit 1 + fi + fallback_graph=$(jq ".runtimes[\"""$non_portable_rid""\"]" "$file") + echo "$fallback_graph" | grep "$portable_rid" + echo "$fallback_graph" | grep "linux" + echo "$fallback_graph" | grep "unix" + echo "$fallback_graph" | grep "base" +done < <(find "${dotnet_dir}" -iname Microsoft.NETCore.App.deps.json -print0)