From b6c7ef2f680cf7361956f613a4ae9cd97d8aa1c2 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 16 Jun 2026 09:52:04 -0600 Subject: [PATCH] dotnet: force PlatformTarget=AnyCPU to fix arm64 host load failure (#9868) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `Microsoft.Z3.dll` was being emitted with PE `Machine=0x8664` (AMD64) despite being pure IL, because the Windows x64 CI environment (`vcvarsall.bat x64`) injects `Platform=x64` into MSBuild, which sets the COFF machine type when `PlatformTarget` is not explicitly specified. This causes `FS0193` / architecture mismatch errors on any arm64 .NET host (macOS Apple Silicon, Linux aarch64, Windows on ARM). ## Changes - **`scripts/mk_util.py`** — Add `AnyCPU` to the in-memory `.csproj` template generated by the Python build system (`mk_win_dist.py`, `mk_unix_dist.py`) - **`src/api/dotnet/Microsoft.Z3.csproj.in`** — Add `AnyCPU` to the CMake build system template Both paths now produce `Machine=0x014C` (i386/AnyCPU) regardless of host or CI environment, matching the assembly's actual nature (`ILONLY=True`, `32BIT_REQUIRED=False`). The native side already ships six RIDs; no changes needed there. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- 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