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

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

To change this default behaviour, add Name property for Application in App.xaml, like
|
1 2 3 |
<Application xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="My.App" Name="My Application"> |
this will change the default title, and codes below will customize the default context menu
|
1 2 3 4 5 |
<NativeMenu.Menu> <NativeMenu> <NativeMenuItem Header="About My App" Command="{Binding AboutCommand}" /> </NativeMenu> </NativeMenu.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
|
1 2 3 4 |
<<span class="pl-ent">Application</span> ... <span class="pl-e">Name</span>=<span class="pl-s"><span class="pl-pds">"</span>Test app<span class="pl-pds">"</span></span>> </<span class="pl-ent">Application</span>> |
Info.plist
|
1 2 3 4 5 6 7 8 |
<<span class="pl-ent">plist</span> <span class="pl-e">version</span>=<span class="pl-s"><span class="pl-pds">"</span>1.0<span class="pl-pds">"</span></span>> <<span class="pl-ent">dict</span>> .... <<span class="pl-ent">key</span>>CFBundleName</<span class="pl-ent">key</span>> <<span class="pl-ent">string</span>>Something else</<span class="pl-ent">string</span>> .... </<span class="pl-ent">dict</span>> </<span class="pl-ent">plist</span>> |
build and publish the app to TestApp.app and then from Finder run the app:

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:
- Always set
CFBundleDisplayNameinInfo.plist - Set
CFBundleNameto the same value - Ensure that
NameinApp.xamlis 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…