maui icon indicating copy to clipboard operation
maui copied to clipboard

publishing Blazor Hybrid MacCatalyst app removes +x on helper apps

Open MeestorX opened this issue 1 year ago • 5 comments

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

MeestorX avatar Jan 07 '24 19:01 MeestorX

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.

ghost avatar Jan 08 '24 04:01 ghost

Could you create a repro project showing how you exactly set this up? cc @rolfbjarne

drasticactions avatar Jan 08 '24 04:01 drasticactions

  1. Create the Blazor Hybrid sample project using dotnet new maui-blazor
  2. Add an executable file to the Resources\Raw folder
  3. dotnet build -f:net8.0-maccatalyst (remove android and ios targets if necessary from the .csproj so it only builds a maccatalyst app)
  4. Once built, Open terminal and open the .app file as a folder and go to the Contents\Resources folder
  5. See if the executable flag is still there for the executable file you had added earlier. In my case, it was intact.
  6. dotnet publish -f:net8.0-maccatalyst
  7. Once built, find the .pkg file and double-click it to install the demo
  8. Go to your /Applications folder and find the app
  9. Open terminal and open the .app file as a folder and go to the Contents\Resources folder
  10. The executable flag on the executable file will show as cleared. Test by trying ./name-of-exectuable

MeestorX avatar Jan 08 '24 15:01 MeestorX

@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.

MeestorX avatar Jan 08 '24 16:01 MeestorX

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!)

MeestorX avatar Jan 08 '24 16:01 MeestorX

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?

rolfbjarne avatar Jan 09 '24 17:01 rolfbjarne

That was it! Damn. I don't know how you figured that one out, but thank you!!

MeestorX avatar Jan 10 '24 16:01 MeestorX