Skip to content

Update Microsoft.Z3 to 5.1.0 for Linux and arm64 native binaries - #61

Merged
HowardvanRooijen merged 3 commits into
feature/miaplaza-expressionutils-1.3.1from
feature/z3-5.1.0
Oct 28, 2026
Merged

HowardvanRooijen merged 3 commits into
feature/miaplaza-expressionutils-1.3.1from
feature/z3-5.1.0

Conversation

@HowardvanRooijen

@HowardvanRooijen HowardvanRooijen commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Why

Microsoft.Z3 4.12.2 ships native binaries for win-x64 and osx-x64 only:

runtimes/osx-x64/native/libz3.dylib
runtimes/win-x64/native/libz3.dll

On Linux the managed assembly loads and then fails at the first solve. In a clean container
that is DllNotFoundException; on a machine that happens to carry an unrelated system
libz3 - as the GitHub Actions runner image does - .NET binds to that instead and fails
with EntryPointNotFoundException: Unable to find an entry point named 'Z3_enable_concurrent_dec_ref'.

The second is the more dangerous outcome: had the runner carried a closer version, every
entry point would have resolved and the tests would have silently run against a solver we
never pinned. It failed loudly by luck.

This is why CI goes red at #48 - the first PR in the stack whose build actually executes a
theorem. #44, #45 and #47 pass because nothing ever loads the native library.

What

Microsoft.Z3 5.1.0 (16 Aug 2026) ships six RIDs:

RID 4.12.2 5.1.0
win-x64 ✅ ✅
osx-x64 ✅ ✅
linux-x64 ❌ ✅
linux-arm64 ❌ ✅
osx-arm64 ❌ ✅
win-arm64 ❌ ✅

PlatformTarget=x64 is dropped as a result - its justifying comment is no longer true, and
pinning x64 would shut arm64 machines out.

Getting the package

Z3 stopped publishing to nuget.org after 4.12.2 and has shipped the .NET package as a GitHub
release asset for twenty releases since. scripts/Install-Z3Package.ps1 fetches it into a
local folder feed, wired to the PreBuild extensibility point so it runs ahead of restore.

Because this comes from a release asset rather than a signed nuget.org package, the download
is pinned by SHA-256 and only moved into the feed once it matches - an interrupted or
substituted download never becomes a package restore will consume. The script is idempotent,
so it costs one hash check per build after the first.

⚠️ Releases are on hold

$SkipPublish = $true. The packed Z3.Linq declares <dependency id="Microsoft.Z3" version="5.1.0" />, and a consumer restoring from nuget.org with a clean cache gets:

error NU1102: Unable to find package Microsoft.Z3 with version (>= 5.1.0)
  - Found 14 version(s) in nuget.org [ Nearest version: 4.12.2 ]

NuGet gives a package no way to tell consumers where its dependencies live, so no feed we
control can fix this - only an upstream publish can. See #60 for what lifts the hold, and
Z3Prover/z3#10711 upstream, where the blocker is package signing bandwidth rather than
willingness.

Note the published package is already broken on Linux and arm64 for the reason above, so
this is not a new limitation - it is the fix for one, waiting on distribution.

Verification

  • Ubuntu 24.04 container (glibc 2.39, matching ubuntu-latest), .NET 10.0.400: builds
    clean and the full suite passes. The same container on 4.12.2 fails 36 of 39.
  • Windows x64: builds clean, 39/39 pass.
  • Full demo output diffed between 4.12.2 and 5.1.0 - both Sudoku puzzles, the oil
    purchase LP ($90,500) and the warehouse LP ($200,000) are identical, and Missionaries &
    Cannibals reaches the same optimum under both Optimize() and orderby. Only unoptimised
    Solve() returns a different valid model, which is expected where the constraints admit
    many.
  • API surface: all 40 Microsoft.Z3 members Z3.Linq calls are present in 5.1.0, and
    Model.Eval still takes its completion parameter.
  • ./build.ps1 FullBuildAndPublish - 35 tasks, 0 errors, 0 warnings, and reports
    Task /FullBuildAndPublish/Publish skipped.

Stack created with GitHub Stacks CLI • Give Feedback 💬

Copilot AI lite review requested due to automatic review settings September 1, 2026 13:22
@HowardvanRooijen HowardvanRooijen changed the title feature/z3 5.1.0 Update Microsoft.Z3 to 5.1.0 for Linux and arm64 native binaries Sep 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the repo to consume Microsoft.Z3 5.1.0 (from GitHub releases rather than nuget.org) and removes the global x64 platform pin so Linux/arm64 environments can resolve the correct native binaries.

Changes:

  • Bump central Microsoft.Z3 package version to 5.1.0 and document the GitHub-release/local-feed approach.
  • Add scripts/Install-Z3Package.ps1 plus a root NuGet.config that registers a local folder feed for Z3.
  • Hook the build to populate the feed before restore, and add repo plumbing (_z3-feed placeholder + ignores).

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
solutions/Directory.Packages.props Bumps Microsoft.Z3 to 5.1.0 and documents local-feed + hash pinning.
solutions/Directory.Build.props Removes PlatformTarget so arm64 machines aren’t forced to x64.
scripts/Install-Z3Package.ps1 New idempotent installer that downloads the Z3 .nupkg from GitHub and verifies SHA-256.
NuGet.config Registers _z3-feed as an additional package source for restore.
.zf/config.ps1 Ensures the Z3 package is installed before restore; temporarily disables publish.
.gitignore Ignores downloaded Z3 .nupkg artifacts in _z3-feed.
_z3-feed/.gitkeep Adds a committed placeholder so the local feed directory exists.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit 10883d8. ± Comparison against base commit c313503.

♻️ This comment has been updated with latest results.

HowardvanRooijen and others added 3 commits September 1, 2026 15:00
Microsoft.Z3 4.12.2 contains native binaries for win-x64 and osx-x64 only.
On Linux the managed assembly therefore loads and then fails at the first
solve, either with DllNotFoundException or - where the machine happens to
have an unrelated system libz3, as the GitHub Actions runner image does -
with EntryPointNotFoundException against a solver we never pinned. That is
why the build goes red as soon as a stage actually executes a theorem.

5.1.0 ships linux-x64, linux-arm64, osx-x64, osx-arm64, win-x64 and
win-arm64. Verified by running the solution on Ubuntu 24.04 (glibc 2.39,
matching ubuntu-latest) as well as Windows, and by diffing the full demo
output between 4.12.2 and 5.1.0: the Sudoku, oil purchase and warehouse
results are identical, and Missionaries & Cannibals still reaches the same
optimum under both Optimize() and orderby. Only the unoptimised Solve()
picks a different valid model, which is expected where the constraints
admit many.

The Z3 project stopped publishing to nuget.org after 4.12.2 and now ships
the package as a GitHub release asset, so it is fetched into a local folder
feed before restore. The download is pinned by SHA-256 and only moved into
the feed once it matches, so an interrupted or substituted download cannot
become a package that restore consumes.

PlatformTarget is dropped now that arm64 binaries exist - pinning x64 would
shut those machines out.

NOTE: this is not yet safe to publish. The packed Z3.Linq declares a
dependency on Microsoft.Z3 5.1.0, which does not exist on nuget.org, so a
consumer restoring Z3.Linq from nuget.org fails with NU1102. The published
package's dependency has to be settled before this is released.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The packed Z3.Linq declares a dependency on Microsoft.Z3 5.1.0, which is not
published to nuget.org, so a consumer restoring from nuget.org with a clean
cache fails with NU1102. NuGet gives a package no way to tell consumers where
its dependencies live, so no feed we control can fix that - only an upstream
publish can.

$SkipPublish keeps a tagged build from shipping an unrestorable package in the
meantime. Verified: FullBuildAndPublish reports "Publish skipped" and still
completes the package stage.

See #60 for what lifts the hold, and Z3Prover/z3#10711 upstream.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The README told everyone to target x64, which stops being true with this
change: 5.1.0 carries native binaries for x64 and arm64 on all three platforms,
so AnyCPU resolves the right one.

The note is there because the advice does not apply to anything on nuget.org
yet. Published versions depend on Microsoft.Z3 4.12.2, which has no Linux or
arm64 binaries, so on those platforms they restore and then throw
DllNotFoundException on the first solve - a failure worth naming, since it
looks like a bug in this library rather than a missing native. Releases are
paused until upstream publishes (#60).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@HowardvanRooijen
HowardvanRooijen merged commit 363260f into main Oct 28, 2026
14 of 15 checks passed
@HowardvanRooijen
HowardvanRooijen deleted the feature/z3-5.1.0 branch October 28, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no_release Suppresses auto_release functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants