Avalonia
Avalonia copied to clipboard
failed to open packed App on macOS
Describe the bug I used Dotnet.Bundle package and MSBuild command to generate macOS bundle. But the binary failed to start. However, if I launch the application directly through the command line using:
/LauncherX.Avalonia.app/Contents/MacOS/LauncherX.Avalonia
The application will start normally.
To Reproduce Steps to reproduce the behavior:
- Add Dotnet.Bundle package
- Add following configuration in .csproj:
<PropertyGroup Condition="'$(IsOSX)'=='true'">
<CFBundleName>$(AssemblyName)</CFBundleName>
<CFBundleDisplayName>$(AssemblyName)</CFBundleDisplayName>
<CFBundleIdentifier>com.$(username).$(AssemblyName)</CFBundleIdentifier>
<CFBundleVersion>1.0.0</CFBundleVersion>
<CFBundlePackageType>APPL</CFBundlePackageType>
<!--<CFBundleSignature>????</CFBundleSignature>-->
<CFBundleExecutable>$(AssemblyName)</CFBundleExecutable>
<CFBundleIconFile>Assets/app.icns</CFBundleIconFile>
<NSPrincipalClass>NSApplication</NSPrincipalClass>
<NSHighResolutionCapable>true</NSHighResolutionCapable>
<CFBundleShortVersionString>1.0</CFBundleShortVersionString>
<!-- Optional -->
<NSRequiresAquaSystemAppearance>true</NSRequiresAquaSystemAppearance>
</PropertyGroup>
- use the following command to build:
dotnet restore -r osx-x64
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-x64 -property:Configuration=Release -p:UseAppHost=true
- get the bundle
Expected behavior Application should launch successfully without crashing.
Screenshots and Logs
Desktop (please complete the following information):
- OS: macOS Monterey
- Version 12.6
Your app appears to be throwing a managed exception, try logging it in Main in program.cs . One common cause of this is the current directory is different when a program is run as a .app .
Bundle also contains stuff related to requested permissions. If the problem is not related to the working directory, it's probably permission-related.
Your app appears to be throwing a managed exception, try logging it in Main in program.cs . One common cause of this is the current directory is different when a program is run as a .app .
But it seems I can run the executable using the terminal command.
Also check Console macOS app, as it can contain additional information about your app why it was closed/crashed. Especially if it's related to some permissions or security related problems.
Your app appears to be throwing a managed exception, try logging it in Main in program.cs . One common cause of this is the current directory is different when a program is run as a .app .
But it seems I can run the executable using the terminal command.
running as a .app runs in a different environment to running the exe directly as in your command line, one thing that is different is the working directory another is probably security options. I have had exactly the same thing happen, logging the exception should tell you the issue.
Problem solved. I just changed the path for the conf file. Now everything is working as expected!