Skip to content

Core - ARM64 support for .Net 4.8.1 (rebased)#5267

Open
amaitland wants to merge 3 commits into
masterfrom
ter-805-arm64-target
Open

Core - ARM64 support for .Net 4.8.1 (rebased)#5267
amaitland wants to merge 3 commits into
masterfrom
ter-805-arm64-target

Conversation

@amaitland

@amaitland amaitland commented Jun 26, 2026

Copy link
Copy Markdown
Member

Fixes #4155

Summary by CodeRabbit

  • New Features
    • Added ARM64 build and packaging support across the solution, including examples and test/runtime identifiers.
    • Updated architecture detection so the correct ARM64 resources are loaded automatically.
    • Expanded NuGet/package contents and build wiring to include ARM64 binaries and locale resources.
  • Bug Fixes
    • Improved ARM64 build handling for output/signing/copy steps to ensure ARM64 artifacts are produced and included correctly.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: befe990d-64dc-44c7-87a9-e45e036de4c1

📥 Commits

Reviewing files that changed from the base of the PR and between 6bf720e and 4c02c35.

📒 Files selected for processing (22)
  • CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj
  • CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj
  • CefSharp.Core.Runtime/CefSharp.Core.Runtime.vcxproj
  • CefSharp.Native.props
  • CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj
  • CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.netcore.csproj
  • CefSharp.Test/CefSharp.Test.csproj
  • CefSharp.Test/CefSharp.Test.netcore.csproj
  • CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj
  • CefSharp.WinForms.Example/CefSharp.WinForms.Example.netcore.csproj
  • CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj
  • CefSharp.Wpf.Example/CefSharp.Wpf.Example.netcore.csproj
  • CefSharp.Wpf.HwndHost.Example/CefSharp.Wpf.HwndHost.Example.csproj
  • CefSharp.Wpf.HwndHost.Example/CefSharp.Wpf.HwndHost.Example.netcore.csproj
  • CefSharp/CefRuntime.cs
  • CefSharp/CefSharp.csproj
  • CefSharp/DependencyChecker.cs
  • CefSharp3.sln
  • NuGet/CefSharp.Common.nuspec
  • NuGet/CefSharp.Common.props
  • NuGet/CefSharp.Common.targets
  • build.ps1
🚧 Files skipped from review as they are similar to previous changes (16)
  • CefSharp/CefSharp.csproj
  • CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj
  • CefSharp.Wpf.HwndHost.Example/CefSharp.Wpf.HwndHost.Example.csproj
  • CefSharp.Test/CefSharp.Test.netcore.csproj
  • CefSharp/DependencyChecker.cs
  • CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj
  • CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj
  • NuGet/CefSharp.Common.nuspec
  • CefSharp.WinForms.Example/CefSharp.WinForms.Example.netcore.csproj
  • CefSharp.Wpf.HwndHost.Example/CefSharp.Wpf.HwndHost.Example.netcore.csproj
  • NuGet/CefSharp.Common.props
  • CefSharp.Test/CefSharp.Test.csproj
  • CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj
  • CefSharp.Core.Runtime/CefSharp.Core.Runtime.vcxproj
  • CefSharp/CefRuntime.cs
  • CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj

📝 Walkthrough

Walkthrough

ARM64 build targets are added across the solution, native and managed projects, runtime lookup code, and NuGet packaging files. CefRuntime now resolves architecture-specific assets using RuntimeInformation.ProcessArchitecture, and package metadata includes win-arm64 outputs and dependencies.

Changes

ARM64 build and packaging support

Layer / File(s) Summary
Native solution and project configs
CefSharp3.sln, CefSharp.BrowserSubprocess.Core/..., CefSharp.Core.Runtime/...
arm64 is added to solution configurations, native project settings, build paths, compiler/linker settings, and precompiled-header conditions.
Managed project platform settings
CefSharp.BrowserSubprocess/..., CefSharp.OffScreen.Example/*, CefSharp.Test/*, CefSharp.WinForms.Example/*, CefSharp.Wpf.Example/*, CefSharp.Wpf.HwndHost.Example/*
Managed projects add arm64 platform entries and win-arm64 runtime identifiers, while the BrowserSubprocess post-build command adds an ARM64 branch.
Architecture-aware runtime loading
CefSharp/CefRuntime.cs, CefSharp/CefSharp.csproj, CefSharp/DependencyChecker.cs
AnyCPU runtime loading uses RuntimeInformation.ProcessArchitecture, with corresponding package and documentation updates.
Package asset declarations
CefSharp.Native.props, NuGet/CefSharp.Common.props, NuGet/CefSharp.Common.nuspec
ARM64 locale items, binary globs, runtime dependencies, and packaged native artifacts are declared.
NuGet targets and build script
NuGet/CefSharp.Common.targets, build.ps1
ARM64 output linking, restore-copy handling, and supported-architecture packaging logic are added.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant CefRuntime
  participant RuntimeInformation
  participant FileSystem
  Application->>CefRuntime: Request AnyCPU runtime loading
  CefRuntime->>RuntimeInformation: Read ProcessArchitecture
  CefRuntime->>FileSystem: Resolve and load architecture-specific runtime
  FileSystem-->>CefRuntime: Return assembly or file-not-found result
  CefRuntime-->>Application: Complete loading or raise error
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only says "Fixes #4155" and omits the required summary, changes, testing, and checklist sections. Expand the PR description to fill the template sections: summary, changes, testing details, type of changes, and checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: ARM64 support for .NET Framework 4.8.1.
Linked Issues check ✅ Passed The changes add ARM64 build, packaging, and runtime support while leaving native components unchanged, matching #4155.
Out of Scope Changes check ✅ Passed No clearly unrelated changes are present; the edits all support ARM64 compilation, packaging, or runtime loading.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ter-805-arm64-target

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="if $(PlatformName) == x86 (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars32.bat&quot;&#xD;&#xA; editbin /largeaddressaware /TSAWARE &quot;$(TargetPath)&quot; &#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;) else (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars64.bat&quot;&#xD;&#xA; editbin /TSAWARE /STACK:8388608 &quot;$(TargetPath)&quot;&#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;)" />
<Exec Command="if $(PlatformName) == x86 (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars32.bat&quot;&#xD;&#xA; editbin /largeaddressaware /TSAWARE &quot;$(TargetPath)&quot; &#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;) else if $(PlatformName) == x64 (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars64.bat&quot;&#xD;&#xA; editbin /TSAWARE /STACK:8388608 &quot;$(TargetPath)&quot;&#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;) else if $(PlatformName) == arm64 (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvarsamd64_arm64.bat&quot;&#xD;&#xA; editbin /TSAWARE /STACK:8388608 &quot;$(TargetPath)&quot;&#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;)" />

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Need to verify the output with dumpbin

@amaitland amaitland left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Needs minor tweaks

Comment thread CefSharp/CefRuntime.cs
string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
string archSpecificPath = Path.Combine(basePath,
Environment.Is64BitProcess ? "x64" : "x86",
RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can extract this into a static field for reuse

Comment thread build.ps1
Comment on lines -495 to +499
$ARCHES.Remove("arm64")
$CefSln = Join-Path $WorkingDir 'CefSharp3.sln'
$NugetPackagePath = "nuget";
$NupkgFiles = @('CefSharp.Common.nuspec', 'CefSharp.WinForms.nuspec', 'CefSharp.Wpf.nuspec', 'CefSharp.OffScreen.nuspec')
$VCXProjPackageConfigFiles = @('CefSharp.Core.Runtime\packages.CefSharp.Core.Runtime.config', 'CefSharp.BrowserSubprocess.Core\packages.CefSharp.BrowserSubprocess.Core.config');
$SupportedArches.AddRange(@("x86", "x64"));
$SupportedArches.AddRange(@("x86", "x64", "arm64"));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I stripped this down to the bare minimum, additional changes to support native arm64 compilation can be added in a followup PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@build.ps1`:
- Around line 495-499: The default multi-arch path now includes arm64, but VSX
still bootstraps the VC environment from only the first entry in $ARCHES, so the
arm64 build can inherit the wrong toolset. Update the VC setup logic in VSX to
select an arm64-capable vcvarsall mode whenever the arches list contains arm64,
or otherwise ensure the initial bootstrap matches the architectures being built
instead of always using $ARCHES[0].

In `@CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj`:
- Line 45: The build step in CefSharp.BrowserSubprocess.csproj uses the
x64-to-ARM64 cross toolchain for the arm64 branch, which is incorrect for native
ARM64 Visual Studio environments. Update the Exec command in the browser
subprocess project so the arm64 path uses the native ARM64 vcvars bootstrap (or
branches on host architecture to choose the right vcvars entrypoint) before
running editbin and sn, keeping the existing x86 and x64 behavior unchanged.

In `@NuGet/CefSharp.Common.targets`:
- Around line 472-475: The AnyCPU restore-copy path in CefSharp.Common.targets
updates the x86/x64 destination properties but leaves the arm64 destination
unmodified, so the arm64 payload is copied to the root instead of an arm64
subfolder. Update the property group that defines CefRedistArm64TargetDir so the
AnyCPU case appends arm64\ in the same way CefRedist32TargetDir and
CefRedist64TargetDir append x86\ and x64\, and keep the change aligned with the
AnyCPU restore-copy target that now includes arm64.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6d80cf05-8ab1-46c2-9ce7-3da49111f671

📥 Commits

Reviewing files that changed from the base of the PR and between 9f3be65 and df49b95.

📒 Files selected for processing (22)
  • CefSharp.BrowserSubprocess.Core/CefSharp.BrowserSubprocess.Core.vcxproj
  • CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj
  • CefSharp.Core.Runtime/CefSharp.Core.Runtime.vcxproj
  • CefSharp.Native.props
  • CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj
  • CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.netcore.csproj
  • CefSharp.Test/CefSharp.Test.csproj
  • CefSharp.Test/CefSharp.Test.netcore.csproj
  • CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj
  • CefSharp.WinForms.Example/CefSharp.WinForms.Example.netcore.csproj
  • CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj
  • CefSharp.Wpf.Example/CefSharp.Wpf.Example.netcore.csproj
  • CefSharp.Wpf.HwndHost.Example/CefSharp.Wpf.HwndHost.Example.csproj
  • CefSharp.Wpf.HwndHost.Example/CefSharp.Wpf.HwndHost.Example.netcore.csproj
  • CefSharp/CefRuntime.cs
  • CefSharp/CefSharp.csproj
  • CefSharp/DependencyChecker.cs
  • CefSharp3.sln
  • NuGet/CefSharp.Common.nuspec
  • NuGet/CefSharp.Common.props
  • NuGet/CefSharp.Common.targets
  • build.ps1

Comment thread build.ps1
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="if $(PlatformName) == x86 (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars32.bat&quot;&#xD;&#xA; editbin /largeaddressaware /TSAWARE &quot;$(TargetPath)&quot; &#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;) else (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars64.bat&quot;&#xD;&#xA; editbin /TSAWARE /STACK:8388608 &quot;$(TargetPath)&quot;&#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;)" />
<Exec Command="if $(PlatformName) == x86 (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars32.bat&quot;&#xD;&#xA; editbin /largeaddressaware /TSAWARE &quot;$(TargetPath)&quot; &#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;) else if $(PlatformName) == x64 (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars64.bat&quot;&#xD;&#xA; editbin /TSAWARE /STACK:8388608 &quot;$(TargetPath)&quot;&#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;) else if $(PlatformName) == arm64 (&#xD;&#xA; call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvarsamd64_arm64.bat&quot;&#xD;&#xA; editbin /TSAWARE /STACK:8388608 &quot;$(TargetPath)&quot;&#xD;&#xA; sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&#xD;&#xA;)" />

@coderabbitai coderabbitai Bot Jun 26, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

For Visual Studio 2022 C++ command-line environments, what vcvars batch file should be used when the host machine is Windows ARM64 and the target architecture is ARM64?

💡 Result:

When the host machine is Windows ARM64 and you are targeting ARM64, the recommended approach is to use the vcvarsall.bat batch file with the arm64 argument [1]. To initialize the environment, execute the following command in your command-line shell: "C:\Program Files\Microsoft Visual Studio\2022[Edition]\VC\Auxiliary\Build\vcvarsall.bat" arm64 Replace [Edition] with your specific Visual Studio 2022 edition (e.g., Community, Professional, or Enterprise). Using the arm64 argument invokes the native ARM64-hosted toolchain, which is the correct environment for building ARM64 binaries on an ARM64 machine [2][1]. While some cross-compilation batch files exist for other scenarios (such as vcvarsamd64_arm64.bat for x64-to-ARM64 builds), they are not appropriate when the host is already ARM64, as using an emulated or cross-hosted environment can lead to issues, such as the inability to correctly utilize certain compiler switches like /arm64EC [3][2]. Alternatively, Visual Studio 2022 provides an "ARM64 Developer Command Prompt" shortcut in the Start menu that automatically runs this configuration for you [3].

Citations:


Use the native ARM64 vcvars bootstrap here. vcvarsamd64_arm64.bat is the x64→ARM64 cross-environment; on ARM64-hosted VS this should use vcvarsall.bat arm64 (or branch on host architecture) so editbin and sn run under the native ARM64 toolchain.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj` at line 45, The
build step in CefSharp.BrowserSubprocess.csproj uses the x64-to-ARM64 cross
toolchain for the arm64 branch, which is incorrect for native ARM64 Visual
Studio environments. Update the Exec command in the browser subprocess project
so the arm64 path uses the native ARM64 vcvars bootstrap (or branches on host
architecture to choose the right vcvars entrypoint) before running editbin and
sn, keeping the existing x86 and x64 behavior unchanged.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

CI is only going to cross compile so that's the priority, native compilation support can be added in a follow up PR.

show proposed change for future reference.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@amaitland, makes sense — if CI is only doing x64-hosted cross-compilation for this PR, I’m happy to treat native ARM64-hosted VS support as follow-up work.

For future reference, here’s the shape of the change I had in mind for Line 45, keeping the existing x86/x64 behavior unchanged and only making the arm64 path host-aware:

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
  <Exec Command="if $(PlatformName) == x86 (&`#xD`;&`#xA`;  call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars32.bat&quot;&`#xD`;&`#xA`;  editbin /largeaddressaware /TSAWARE &quot;$(TargetPath)&quot;&`#xD`;&`#xA`;  sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&`#xD`;&`#xA`;) else if $(PlatformName) == x64 (&`#xD`;&`#xA`;  call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvars64.bat&quot;&`#xD`;&`#xA`;  editbin /TSAWARE /STACK:8388608 &quot;$(TargetPath)&quot;&`#xD`;&`#xA`;  sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&`#xD`;&`#xA`;) else if $(PlatformName) == arm64 (&`#xD`;&`#xA`;  if /I &quot;%PROCESSOR_ARCHITECTURE%&quot; == &quot;ARM64&quot; (&`#xD`;&`#xA`;    call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvarsall.bat&quot; arm64&`#xD`;&`#xA`;  ) else (&`#xD`;&`#xA`;    call &quot;$(DevEnvDir)..\..\VC\Auxiliary\Build\vcvarsamd64_arm64.bat&quot;&`#xD`;&`#xA`;  )&`#xD`;&`#xA`;  editbin /TSAWARE /STACK:8388608 &quot;$(TargetPath)&quot;&`#xD`;&`#xA`;  sn -R &quot;$(TargetPath)&quot; &quot;$(ProjectDir)..\CefSharp.snk&quot;&`#xD`;&`#xA`;)" />
</Target>

That would preserve the current CI path while also handling native ARM64-hosted developer environments later.

If you want, I can also open a follow-up issue for that so it doesn’t get lost.

Comment thread NuGet/CefSharp.Common.targets
@AppVeyorBot

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

A stacked PR containing fixes has been created.

  • Stacked PR: #5268
  • Files modified:
  • CefSharp.BrowserSubprocess/CefSharp.BrowserSubprocess.csproj

Time taken: 2m 46s

@AppVeyorBot

Copy link
Copy Markdown

@amaitland amaitland force-pushed the ter-805-arm64-target branch from 6bf720e to 4c02c35 Compare July 12, 2026 09:01
@AppVeyorBot

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request - ARM64 support on .NET Framework 4.8.1

2 participants