From 178879e1846e0819a99c6c92827ca03789620bb3 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 15 Jun 2026 14:35:23 +0000
Subject: [PATCH] Fix .NET wrapper PE Machine field: add PlatformTarget AnyCPU
to prevent x64-only DLL
The managed Microsoft.Z3.dll was being built with Machine=0x8664 (AMD64)
because the Windows x64 CI environment (vcvarsall.bat x64) sets the MSBuild
Platform=x64 environment variable, which causes dotnet build to emit an x64
PE header even though the assembly is pure IL (ILONLY=True).
Fix: explicitly set AnyCPU in both build paths:
- scripts/mk_util.py: csproj template used by Python build system
(mk_win_dist.py, mk_unix_dist.py)
- src/api/dotnet/Microsoft.Z3.csproj.in: csproj template used by CMake build
This produces Machine=0x014C (i386/AnyCPU) so arm64 .NET hosts on macOS,
Linux and Windows can load the wrapper without error FS0193.
Closes #9863
---
scripts/mk_util.py | 1 +
src/api/dotnet/Microsoft.Z3.csproj.in | 1 +
2 files changed, 2 insertions(+)
diff --git a/scripts/mk_util.py b/scripts/mk_util.py
index ff04bfb68..89d82303a 100644
--- a/scripts/mk_util.py
+++ b/scripts/mk_util.py
@@ -1804,6 +1804,7 @@ class DotNetDLLComponent(Component):
Z3 is a satisfiability modulo theories solver from Microsoft Research.
Copyright Microsoft Corporation. All rights reserved.
smt constraint solver theorem prover
+ AnyCPU
%s
diff --git a/src/api/dotnet/Microsoft.Z3.csproj.in b/src/api/dotnet/Microsoft.Z3.csproj.in
index cf5aacf46..55cb100be 100644
--- a/src/api/dotnet/Microsoft.Z3.csproj.in
+++ b/src/api/dotnet/Microsoft.Z3.csproj.in
@@ -60,6 +60,7 @@
4
true
$(OutputPath)\Microsoft.Z3.xml
+ AnyCPU