信创环境 / 经验分享 · 2025年10月26日

Modify the default context title “Avalonia Application” and related context menu in MacOS

When running your projecton MacOS , the title “Avalonia Application” appears in the upper bar

titlebar

Also there is an “About” submenu that opens this dialog:

about

To change this default behaviour, add Name property for Application in App.xaml, like

this will change the default title, and codes below will customize the default context menu

More information in github

When you set Name in your App.xaml but package your app in a bundle you’ll find that if you set CFBundleName in the Info.plist to something else then macOS will use the value from CFBundleName

For example:

App.xaml

Info.plist

build and publish the app to TestApp.app and then from Finder run the app:

appname

You could omit CFBundleName from the Info.plist in the app bundle, however if you have CFBundleDisplayName specified then macOS will use that value as the title for the app.

When you specify both CFBundleName and CFBundleDisplayName then CFBundleName takes precedence.

The Apple Developer docs specify that CFBundleName:

may be displayed to users in situations such as the absence of a value for CFBundleDisplayName

Whereas CFBundleDisplayName documentation states:

specifies the display name of the bundle, visible to users and used by Siri.
Which means that this is a key you should most probably always include in your app bundle.

So to reduce the amount of head-scratching and debugging for other people, my recommendation would be to:

  1. Always set CFBundleDisplayName in Info.plist
  2. Set CFBundleName to the same value
  3. Ensure that Name in App.xaml is set to the same value

Depending on the build configuration it seems like a smart idea to generate the contents of Info.plist at publish time based on the Name in App.xaml.

I’ll create a PR on the Avalonia documentation site to make sure this appears there too.

Note: I tried to actually call AvaloniaNativePlatform.SetupApplicationName() somewhere after the app starts but whatever you provide there is ignored by macOS.

Note 2: This all of course doesn’t show up when you launch the app from Rider or the output directory…