Skip to content

Allow the use of .NET Core 10#4331

Merged
mhsmith merged 29 commits intobeeware:mainfrom
freakboy3742:win-arm64
Apr 23, 2026
Merged

Allow the use of .NET Core 10#4331
mhsmith merged 29 commits intobeeware:mainfrom
freakboy3742:win-arm64

Conversation

@freakboy3742
Copy link
Copy Markdown
Member

@freakboy3742 freakboy3742 commented Apr 16, 2026

Allows the Winforms backend to use .NET Core 10, instead of .NET Framework 4.x.

This is required to add native Windows on ARM support - Windows 10 and 11 both provide .NET Framework 4.x (aka netfx) out of the box, but on ARM machines, it's an x86-64 build.

This adds in a loader configuration that will try to use .NET Core 10; if .NET 10 can't be found, it will try to fall back on .NET Framework 4.x. When running on ARM with a native ARM Python interpreter, this fallback will fail, so an error is raised.

In addition to the .NET loading changes, the changes in this PR are:

  • Changes in class names for status icons
  • Windows not accurately restoring the window size when returning from FULLSCREEN or PRESENTATION.
  • Fixes to the testbed due to slightly different behavior in folder selection dialogs
  • The need for an ARM binary for WebView2 (and related changes to packaging so we have a py3-none-win_arm64 and py3-none-win_amd64 binary wheels.

With the changes in this PR, the testbed passes to completion in my test environment with a small number of errors related to discrepancies caused by the virtualisation environment (discrepancies between \\drive\location and z:\location path descriptions).

However, the testbed doesn't pass using the windows-11-arm environment, as that runner is configured as a non-interactive/headless environment. This means that no window ever gains focus, and we have no ability to test focus changes, dialog display, etc. See actions/partner-runner-images#174 for details.

So - this PR does a full CI pass on both .NET Framework 4.x and .NET Core 10 on Windows/x86-64, validating that the .NET Core APIs work; but only does a basic "does the app start?" test for Windows/ARM64.

Two design decisions implicit in this PR:

  • We are continuing to support .NET Framework 4.x. This is available by default on Windows 10 and 11, so it means all Toga apps will Just Work. The .NET Desktop runtime is widely installed, but isn't guaranteed to be installed. It would definitely be easier to only support .NET 10, but I'm not sure that's a great user experience. We can add a "this app requires .NET 10" to an MSI installer - but we can't easily bundle .NET 10 with an MSI installer (at least, not in a way that yields a single simple MSI).
  • We will continuing to support Windows 10. Win10 is strictly EOL, so we could drop it. If we did, I think we can go back to a pure Python Winforms wheel. The binary wheel is only needed because Windows 10 doesn't include the WebView2 runtime;0 Windows 11 does. If we drop Windows 10 support, we could simplify that part of the code as well.

However, my read is that Windows users are the least likely to be on the "bleeding edge" when it comes to new tech - we still get requests for restoring Windows 7/8 support - so dropping Windows 10 (even though it is EOL) is probably not a good idea quite yet.

Support for Windows/ARM64 has been merged into Briefcase; I've manually published stub binaries for Python 3.12 so that briefcase run works. See beeware/briefcase-windows-VisualStudio-template#89 for some template tweaks that are needed to tag those binaries.

Fixes #2782.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@freakboy3742 freakboy3742 marked this pull request as draft April 16, 2026 04:11
@freakboy3742
Copy link
Copy Markdown
Member Author

Two issues revealed by CI testing:

  1. There's a chicken and egg problem: We can't run testbed on Toga until Briefcase supports ARM; we can't run CI on Briefcase until Toga supports ARM.
  2. There are a handful of APIs that are actually different on .NET Core. This appears to be mostly an issue with MenuItem and StatusIcon objects. I'm not yet sure if the best solution is to hard switch to .NET core, or if there's a compatibility path that will allow both.

@johnzhou721
Copy link
Copy Markdown
Contributor

For the purposes of Toga, we should totally switch to .NET 10 IMHO. .NET 10 WinForms have out-of-the-box Dark Mode support, and more WinForms improvements.

Not familiar with the compatibility issues... however just giing my opinion on whether to switch to .NET. 10 instead of using older .NET.

@freakboy3742
Copy link
Copy Markdown
Member Author

The biggest compatibility issue is "Windows doesn't ship with .NET Core", so most users will run a Toga app and then get an error. It's not a hard error to fix... unless you don't have admin rights to install new software - and a lot of Toga users won't be.

@johnzhou721
Copy link
Copy Markdown
Contributor

@freakboy3742 Hmm... is it possible to bundle .NET Core with your application, then? This may need a PR to the Visual Studio template.

@johnzhou721
Copy link
Copy Markdown
Contributor

@freakboy3742 FYI: We should update to ContextMenuStrip anyways regardless of .NET 10 support status — which is available even in .NET 4.0. ContextMenu class is already flagged as "binary compatibility only" in docs: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.contextmenu?view=windowsdesktop-10.0 — and it appears that MS has finally pulled the plug and removed it in .NET 10.

But also, since Winforms context menus aren't very native-looking as seen in the DetailedList PR, might as well get Oliver-Leigh to win32 everything for context menus and menustrips.

@freakboy3742 freakboy3742 marked this pull request as ready for review April 22, 2026 07:35
@freakboy3742 freakboy3742 requested a review from mhsmith April 22, 2026 07:35
@freakboy3742 freakboy3742 mentioned this pull request Apr 22, 2026
4 tasks
@mhsmith
Copy link
Copy Markdown
Member

mhsmith commented Apr 22, 2026

  • Win10 is strictly EOL, so we could drop it.

Not entirely: there was an option to pay for 1 year of extended support, and several ways to get it for free (I did, on my old laptop which wasn't Win11 compatible), and it looks like this will continue until 2028.

Comment thread .github/workflows/ci.yml Outdated
Comment thread docs/en/reference/platforms/windows.md Outdated
Comment thread winforms/src/toga_winforms/__init__.py Outdated
Comment thread docs/en/reference/platforms/windows.md Outdated
Comment thread testbed/tests/testbed.py Outdated
Comment thread testbed/tests/app/test_desktop.py Outdated
Comment thread winforms/src/toga_winforms/__init__.py
Comment thread winforms/src/toga_winforms/window.py
@Oliver-Leigh
Copy link
Copy Markdown
Contributor

But also, since Winforms context menus aren't very native-looking as seen in the DetailedList PR, might as well get Oliver-Leigh to win32 everything for context menus and menustrips.

@johnzhou721 This is actually on my to-do list...

freakboy3742 and others added 3 commits April 23, 2026 06:14
Co-authored-by: Malcolm Smith <smith@chaquo.com>
Co-authored-by: Malcolm Smith <smith@chaquo.com>
@freakboy3742 freakboy3742 requested a review from mhsmith April 22, 2026 22:43
@johnzhou721
Copy link
Copy Markdown
Contributor

FWIW: My earlier remark re: ContextMenu and/or other menu classes being deprecated in .NET Framework 3.1 was incorrect. It was deprecated in .NET Core 3.1, and although ContextMenuStrip etc. exists in .NET Framework 3.1 as well, it's less native, so the current approach of if-elsing .NETfx and .NETCore works, as it will allow .NET framework menus to become more native before the slightly mysterious Oliver-Leigh comes and Win32s everything.

@mhsmith mhsmith merged commit 464300c into beeware:main Apr 23, 2026
62 checks passed
@freakboy3742 freakboy3742 deleted the win-arm64 branch April 23, 2026 21:35
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.

Add support for native arm64 Windows

4 participants