Skip to content

Instantly share code, notes, and snippets.

@stand-sure
Last active December 1, 2023 18:53
Show Gist options
  • Save stand-sure/465604e314a931d7a9a9e9dfe11bc566 to your computer and use it in GitHub Desktop.
Save stand-sure/465604e314a931d7a9a9e9dfe11bc566 to your computer and use it in GitHub Desktop.
scripts for getting package and project references from csproj files
#! /usr/bin/env bash
for file in src/**/*.csproj
do
cat $file | \
xq '[(try(.Project.ItemGroup[].PackageReference) // [])] | flatten' | \
jq '[.[].["@Include"]]' | \
jq --arg file ${file} '{"file":$file, "refs":.}' | \
yq eval --prettyPrint '[.]';
done
#! /usr/bin/env bash
for file in src/**/*.csproj
do
cat $file | \
xq '[(try(.Project.ItemGroup[].ProjectReference) // [])] | flatten' | \
jq '[.[].["@Include"]]' | \
jq --arg file ${file} '{"file":$file, "refs":.}' | \
yq eval --prettyPrint '[.]';
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment