diff --git a/.github/workflows/win-build-nonportable.yml b/.github/workflows/win-build-nonportable.yml
new file mode 100644
index 0000000..1b1c7b8
--- /dev/null
+++ b/.github/workflows/win-build-nonportable.yml
@@ -0,0 +1,36 @@
+name: win-build-nonportable
+
+# Controls when the action will run. Triggers the workflow on push or pull request
+# events but only for the master branch
+
+on:
+ push: { branches: [ master ] }
+ pull_request: { branches: [ master ] }
+ release: { types: [published] } # runs on “Publish release” button
+ workflow_dispatch: # lets you run it by hand
+
+jobs:
+ build:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+ name: Checkout Code
+ with:
+ fetch-depth: 0
+
+ - name: Setup .NET SDK
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: '8.0.x'
+
+ - name: Add msbuild to PATH
+ uses: microsoft/setup-msbuild@v1.0.2
+
+ - name: Setup NuGet.exe for use with actions
+ uses: NuGet/setup-nuget@v1.0.5
+
+ - name: Setup Just
+ uses: extractions/setup-just@v3
+
+ - name: Build and test
+ run: just test-win-x64
diff --git a/README-src.md b/README-src.md
index 0536138..0e7c1f5 100644
--- a/README-src.md
+++ b/README-src.md
@@ -21,6 +21,9 @@ In particular, if you only want to read graphs and run the DOT layout algorithm,
To run our tests successfully you will also need libgts and libpcre2 (for the neato algorithm).
For more details, check the dependencies of any graphviz binaries with `ldd`.
+It is currently not possible to use this package on linux in a non-portable application, i.e. an application that targets linux-x64.
+The reason for this is that [dotnet flattens the directory structure of native dependencies when targetting a single runtime](https://github.com/dotnet/sdk/issues/9643), and this breaks graphviz.
+
## Installation
Add the [Rubjerg.Graphviz nuget package](https://www.nuget.org/packages/Rubjerg.Graphviz/) to your project.
diff --git a/README.md b/README.md
index 35319ed..a47e081 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,9 @@ In particular, if you only want to read graphs and run the DOT layout algorithm,
To run our tests successfully you will also need libgts and libpcre2 (for the neato algorithm).
For more details, check the dependencies of any graphviz binaries with `ldd`.
+It is currently not possible to use this package on linux in a non-portable application, i.e. an application that targets linux-x64.
+The reason for this is that [dotnet flattens the directory structure of native dependencies when targetting a single runtime](https://github.com/dotnet/sdk/issues/9643), and this breaks graphviz.
+
## Installation
Add the [Rubjerg.Graphviz nuget package](https://www.nuget.org/packages/Rubjerg.Graphviz/) to your project.
diff --git a/Rubjerg.Graphviz.Test/Rubjerg.Graphviz.Test.csproj b/Rubjerg.Graphviz.Test/Rubjerg.Graphviz.Test.csproj
index c81c213..0e7abd5 100644
--- a/Rubjerg.Graphviz.Test/Rubjerg.Graphviz.Test.csproj
+++ b/Rubjerg.Graphviz.Test/Rubjerg.Graphviz.Test.csproj
@@ -9,6 +9,8 @@
true
latest
embedded
+
+ win-x64;linux-x64
diff --git a/Rubjerg.Graphviz.TransitiveTest/Rubjerg.Graphviz.TransitiveTest.csproj b/Rubjerg.Graphviz.TransitiveTest/Rubjerg.Graphviz.TransitiveTest.csproj
index a160b68..90dc3a6 100644
--- a/Rubjerg.Graphviz.TransitiveTest/Rubjerg.Graphviz.TransitiveTest.csproj
+++ b/Rubjerg.Graphviz.TransitiveTest/Rubjerg.Graphviz.TransitiveTest.csproj
@@ -9,6 +9,8 @@
true
latest
embedded
+
+ win-x64;linux-x64
diff --git a/Rubjerg.Graphviz/GraphvizCommand.cs b/Rubjerg.Graphviz/GraphvizCommand.cs
index 7bc4350..faeb172 100644
--- a/Rubjerg.Graphviz/GraphvizCommand.cs
+++ b/Rubjerg.Graphviz/GraphvizCommand.cs
@@ -4,6 +4,7 @@
using System.Reflection;
using System.Text;
using System.Runtime.InteropServices;
+using System.Linq;
namespace Rubjerg.Graphviz;
@@ -33,6 +34,16 @@ internal static string Rid
}
}
+ internal static Lazy _DotExePath = new Lazy(() =>
+ // If graphviz is not found in the runtimes folder, look in the current directory for compatibility with nonportable windows builds.
+ new string[] {
+ Path.Combine(AppContext.BaseDirectory, "runtimes", Rid, "native", "dot"),
+ Path.Combine(AppContext.BaseDirectory, "runtimes", Rid, "native", "dot.exe"),
+ "dot",
+ "dot.exe"
+ }.FirstOrDefault(File.Exists));
+ internal static string DotExePath => _DotExePath.Value;
+
public static RootGraph CreateLayout(Graph input, string engine = LayoutEngines.Dot, CoordinateSystem coordinateSystem = CoordinateSystem.BottomLeft)
{
var (stdout, stderr) = Exec(input, engine: engine);
@@ -56,7 +67,6 @@ public static string ConvertBytesOutputToString(byte[] data)
/// stderr may contain warnings, stdout is in utf8 encoding
public static (byte[] stdout, string stderr) Exec(Graph input, string format = "xdot", string? outputPath = null, string engine = LayoutEngines.Dot)
{
- var exeName = Path.Combine(AppContext.BaseDirectory, "runtimes", Rid, "native", "dot");
string arguments = $"-T{format} -K{engine}";
if (outputPath != null)
{
@@ -71,7 +81,7 @@ public static (byte[] stdout, string stderr) Exec(Graph input, string format = "
?? Path.GetDirectoryName(System.AppContext.BaseDirectory);
// Construct the path to the executable
- string exePath = Path.Combine(exeDirectory, exeName);
+ string exePath = Path.Combine(exeDirectory, DotExePath);
Process process = new Process();
diff --git a/justfile b/justfile
index 0f7be33..651792a 100644
--- a/justfile
+++ b/justfile
@@ -19,6 +19,9 @@ build SOLUTION:
dotnet build {{SOLUTION}} --configuration Release --no-restore; \
fi
+build-rid SOLUTION RID:
+ dotnet build {{SOLUTION}} --configuration Release --no-restore -r {{RID}};
+
# Build nuget package
build-package: restore
just build Rubjerg.Graphviz.sln
@@ -32,9 +35,9 @@ build-tests: restore-tests
just build Rubjerg.Graphviz.Tests.sln
# Run unit tests for a project
-test PROJECT:
+test PROJECT OUTPUT_PATH='bin/x64/Release/net8.0/':
dotnet test --no-build \
- -p:OutputPath=bin/x64/Release/net8.0 \
+ -p:OutputPath={{OUTPUT_PATH}} \
-c Release \
-f net8.0 \
-v d \
@@ -54,6 +57,13 @@ test-nugetorg:
just test NugetOrgTests/Rubjerg.Graphviz.NugetOrgTest/Rubjerg.Graphviz.NugetOrgTest.csproj
just test NugetOrgTests/Rubjerg.Graphviz.NugetOrgTransitiveTest/Rubjerg.Graphviz.NugetOrgTransitiveTest.csproj
+# Build and test nonportable win-x64 deployment
+test-win-x64: restore-tests
+ dotnet build Rubjerg.Graphviz.Test/Rubjerg.Graphviz.Test.csproj --configuration Release --no-restore -r win-x64;
+ dotnet build Rubjerg.Graphviz.TransitiveTest/Rubjerg.Graphviz.TransitiveTest.csproj --configuration Release --no-restore -r win-x64;
+ just test Rubjerg.Graphviz.Test/Rubjerg.Graphviz.Test.csproj bin/Release/net8.0/win-x64/
+ just test Rubjerg.Graphviz.TransitiveTest/Rubjerg.Graphviz.TransitiveTest.csproj bin/Release/net8.0/win-x64/
+
locate-nupkg GITHUB_OUTPUT:
echo "package=$(find . -name "Rubjerg.Graphviz.*.nupkg" | head -1)" >> "{{GITHUB_OUTPUT}}"
@@ -70,7 +80,7 @@ normalize:
bash -c "git ls-files -- ':!GraphvizWrapper/graphvizfiles/*' ':!*.sh' | xargs unix2dos"
# Format the code
-format:
+format:
dotnet format whitespace -v diag Rubjerg.Graphviz.sln
dotnet format whitespace -v diag Rubjerg.Graphviz.Tests.sln