Skip to content

Commit ac7c522

Browse files
ci: skip SignaturesGen AfterBuild exec when target arch != host arch
CI was failing on `dotnet build Reactor.slnx` (windows-latest, x64 host) because the slnx defaults Platform=ARM64 for projects that opt in. The AfterBuild target then runs `Reactor.SignaturesGen.exe` — an ARM64 apphost the x64 host cannot execute, exiting with code 216 ("not compatible with the version of Windows you're running") and producing MSB3073. The previous skip-condition only checked RuntimeIdentifier; this path sets only Platform. Now resolve target arch from Platform/RID and host arch from \$(NETCoreSdkRuntimeIdentifier), and skip regen when they differ. The committed skills/reactor.api.txt is still picked up by pack. Verified locally on win-arm64: -p:Platform=ARM64 → regen runs (target=arm64, host=arm64) -p:Platform=x64 → regen skipped (target=x64, host=arm64) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e983eec commit ac7c522

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

tools/Reactor.SignaturesGen/Reactor.SignaturesGen.csproj

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,28 @@
2323
the Reactor NuGet (see Reactor.csproj) and embedded into the mur CLI.
2424
Invokes the apphost .exe (not `dotnet $(TargetPath).dll`) so the build
2525
works on machines whose `dotnet` host arch differs from $(Platform). -->
26-
<!-- Skip during publish/pack flows that set a RuntimeIdentifier. A propagated
27-
RID may produce a cross-arch exe that the host can't execute (e.g. CI's
28-
`dotnet publish` for win-arm64 running on a windows-x64 runner). The
29-
committed skills/reactor.api.txt is still picked up by pack; regen
30-
happens during the upstream slnx build where no RID is in play. -->
26+
<!-- Skip when the build target arch doesn't match the host arch — otherwise
27+
the apphost is foreign and exits with code 216 ("not compatible with the
28+
version of Windows you're running"). This happens in two CI paths:
29+
(a) `dotnet build Reactor.slnx` on windows-latest (x64 host) where the
30+
slnx default Platform is ARM64.
31+
(b) `dotnet publish` with a cross-arch RuntimeIdentifier (win-arm64
32+
on the x64 runner).
33+
The committed skills/reactor.api.txt is still picked up by pack; regen
34+
only needs to fire on dev machines where $(Platform) matches the host. -->
35+
<PropertyGroup>
36+
<!-- $(NETCoreSdkRuntimeIdentifier) is set by the .NET SDK to the host RID
37+
(e.g. win-x64, win-arm64). Trim everything before the dash. -->
38+
<_ReactorApiHostArch Condition="$(NETCoreSdkRuntimeIdentifier.Contains('-'))">$(NETCoreSdkRuntimeIdentifier.Substring($([MSBuild]::Add($(NETCoreSdkRuntimeIdentifier.IndexOf('-')), 1))).ToLowerInvariant())</_ReactorApiHostArch>
39+
<_ReactorApiTargetArch Condition="'$(Platform)' == 'x64'">x64</_ReactorApiTargetArch>
40+
<_ReactorApiTargetArch Condition="'$(Platform)' == 'ARM64'">arm64</_ReactorApiTargetArch>
41+
<_ReactorApiTargetArch Condition="'$(_ReactorApiTargetArch)' == '' and '$(RuntimeIdentifier)' == 'win-x64'">x64</_ReactorApiTargetArch>
42+
<_ReactorApiTargetArch Condition="'$(_ReactorApiTargetArch)' == '' and '$(RuntimeIdentifier)' == 'win-arm64'">arm64</_ReactorApiTargetArch>
43+
<_ReactorApiTargetArch Condition="'$(_ReactorApiTargetArch)' == ''">$(_ReactorApiHostArch)</_ReactorApiTargetArch>
44+
</PropertyGroup>
3145
<Target Name="EmitReactorApiTxt"
3246
AfterTargets="Build"
33-
Condition="'$(SkipReactorApiGen)' != 'true' and '$(RuntimeIdentifier)' == ''">
47+
Condition="'$(SkipReactorApiGen)' != 'true' and '$(_ReactorApiTargetArch)' == '$(_ReactorApiHostArch)'">
3448
<Exec Command="&quot;$(TargetDir)$(AssemblyName).exe&quot; &quot;$(MSBuildThisFileDirectory)..\..&quot;"
3549
ConsoleToMSBuild="true"
3650
IgnoreExitCode="false" />

0 commit comments

Comments
 (0)