maui
maui copied to clipboard
publishing Blazor Hybrid MacCatalyst app removes +x on helper apps
Description
If I have an app that runs another app, it works fine within dotnet run, dotnet build, but when using dotnet pubish, the app installed from the .pkg file will have the +x attribute cleared on the helper app.
The helper app is contained in Resources/Raw/Mac
within this project.
Steps to Reproduce
Create a dotnet maui-hybrid project. Add a helper app and the appropriate changes to info.plist. dotnet run
and dotnet build
produce an app that the helper app will run, but dotnet publish
does not.
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
macOS
Affected platform versions
MacOS Catalyst
Did you find any workaround?
Not yet, but probably an external packager would not have this issue.
Relevant log output
No response
Hi @MeestorX. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Could you create a repro project showing how you exactly set this up? cc @rolfbjarne
- Create the Blazor Hybrid sample project using
dotnet new maui-blazor
- Add an executable file to the
Resources\Raw
folder -
dotnet build -f:net8.0-maccatalyst
(remove android and ios targets if necessary from the.csproj
so it only builds a maccatalyst app) - Once built, Open terminal and open the .app file as a folder and go to the
Contents\Resources
folder - See if the executable flag is still there for the executable file you had added earlier. In my case, it was intact.
-
dotnet publish -f:net8.0-maccatalyst
- Once built, find the .pkg file and double-click it to install the demo
- Go to your
/Applications
folder and find the app - Open terminal and open the .app file as a folder and go to the
Contents\Resources
folder - The executable flag on the executable file will show as cleared. Test by trying
./name-of-exectuable
@rolfbjarne - Here is a link to the project. It already has the .app
and .pkg
files so you can just check the .app
file and run the .pkg
file if you want to test without building.
If this is not the "approved" way of adding helper executables, then please let me know. I couldn't find any documentation anywhere on the "right" way to add a helper executable to a .NET MAUI app for MacOS. The app is not signed and neither is the helper executable, so maybe MacOS is clearing the executable flag? If so, some guidance would be appreciated on how to stop MacOS from clearing that flag on the helper executable. (Oddly it doesn't clear it on the main executable!)
I think everything is working as expected, although it might be a bit unintuitive.
This are the attributes for the file in the project:
$ ls -la Resources/Raw/ngrok
-rwxr--r--@ 1 rolf staff 26441052 Jan 8 16:36 Resources/Raw/ngrok
and these for the installed app:
$ ls -la /Applications/BlazorHybridTemplate.app/Contents/Resources/Mac/ngrok
-rwxr--r--@ 1 root wheel 26441052 Jan 8 16:36 /Applications/BlazorHybridTemplate.app/Contents/Resources/Mac/ngrok
Note that the execute bit is the same: set for the owner, but for neither the group nor all other users.
The difference is that once the app is installed, it's owned by root - which means that only root can execute the executable once it's installed.
The fix is to add execute permissions to the file in the repository:
$ chmod +x Resources/Raw/ngrok
$ ls -la Resources/Raw/ngrok
-rwxr-xr-x@ 1 rolf staff 26441052 Jan 8 16:36 Resources/Raw/ngrok
and then the file will be executable by everybody once it's installed.
Can you try this to see if it works for you?
That was it! Damn. I don't know how you figured that one out, but thank you!!