Skip to content

Commit

Permalink
Merge pull request #25 from m-carrasco/fix-nuget-issue
Browse files Browse the repository at this point in the history
Fix ssa-query not being found when net-ssa-lib is used as a nuget package.
  • Loading branch information
m-carrasco authored Feb 3, 2024
2 parents 738ffb8 + f96d37a commit 1cb547f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 15 additions & 0 deletions ci/nuget-pack.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 8 additions & 2 deletions net-ssa-lib/queries/SsaQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1cb547f

Please sign in to comment.