From f96d37a2b695178b106e1dd1093f59c4aa2f27fd Mon Sep 17 00:00:00 2001 From: Manuel Carrasco Date: Sat, 3 Feb 2024 18:26:29 +0000 Subject: [PATCH] Fix ssa-query not being found when net-ssa-lib is used as a nuget package. --- .github/workflows/build.yml | 2 +- ci/nuget-pack.sh | 15 +++++++++++++++ net-ssa-lib/queries/SsaQuery.cs | 10 ++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100755 ci/nuget-pack.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8d975b..8943c93 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,7 +145,7 @@ jobs: dotnet test --verbosity normal - name: Generate nuget packages run: | - dotnet pack net-ssa.sln -o:build/bin/net-ssa/package --include-symbols --include-source /p:Version=${{ steps.gitversion.outputs.AssemblySemVer }} /p:AssemblyVersion=${{ steps.gitversion.outputs.AssemblySemVer }} /p:InformationalVersion=${{ steps.gitversion.outputs.InformationalVersion }} /p:PackageVersion=${{ steps.gitversion.outputs.AssemblySemVer }} + ./ci/nuget-pack.sh "${{ steps.gitversion.outputs.AssemblySemVer }}" "${{ steps.gitversion.outputs.AssemblySemVer }}" "${{ steps.gitversion.outputs.InformationalVersion }}" "${{ steps.gitversion.outputs.AssemblySemVer }}" dotnet nuget push build/bin/net-ssa/package/net-ssa-lib.${{ steps.gitversion.outputs.NuGetVersionV2 }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json mirror: diff --git a/ci/nuget-pack.sh b/ci/nuget-pack.sh new file mode 100755 index 0000000..6983217 --- /dev/null +++ b/ci/nuget-pack.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +CURRENT_DIR=$(dirname "$(readlink -f "$0")") + +VERSION=$1 +ASSEMBLY_VERSION=$2 +INFORMATIONAL_VERSION=$3 +PACKAGE_VERSION=$4 + +pushd $CURRENT_DIR/.. + +dotnet pack net-ssa.sln -o:build/bin/net-ssa/package --include-symbols --include-source /p:Version=$VERSION /p:AssemblyVersion=$ASSEMBLY_VERSION /p:InformationalVersion=$INFORMATIONAL_VERSION /p:PackageVersion=$PACKAGE_VERSION + +popd \ No newline at end of file diff --git a/net-ssa-lib/queries/SsaQuery.cs b/net-ssa-lib/queries/SsaQuery.cs index b0d5f11..7857fe8 100644 --- a/net-ssa-lib/queries/SsaQuery.cs +++ b/net-ssa-lib/queries/SsaQuery.cs @@ -49,10 +49,16 @@ public static String GetSsaQueryBinPath() { String suffix = GetTargetSuffix(); string directory = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName; - string result = Path.Combine(directory, "ssa-query" + suffix); + string binaryName = "ssa-query" + suffix; + string result = Path.Combine(directory, binaryName); if (!File.Exists(result)) { - throw new FileNotFoundException(result); + // This will attempt to handle the case where net-ssa-lib is consumed as a nuget package. + // Unfortunately, for this case the binaries are not copied right next to the executing assembly. + result = Path.Combine(Path.Combine(Path.Combine(Path.Combine(directory, ".."), ".."), "content"), binaryName); + if (!File.Exists(result)) { + throw new FileNotFoundException(result); + } } return result;