Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET MAUI macOS target publishing/archiving #5399

Closed
jfversluis opened this issue Mar 17, 2022 · 39 comments
Closed

.NET MAUI macOS target publishing/archiving #5399

jfversluis opened this issue Mar 17, 2022 · 39 comments
Assignees
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) partner/macios Issues for the Mac / iOS SDK platform/macOS 🍏 macOS / Mac Catalyst s/triaged Issue has been reviewed
Milestone

Comments

@jfversluis
Copy link
Member

jfversluis commented Mar 17, 2022

Description

TL;DR

  • Archiving and publishing a .NET MAUI macOS (Mac Catalyst) app (both .NET MAUI and .NET MAUI Blazor) to a .app and .pkg works, I have been able to sign the binary as well as use it unsigned.
  • This is all through the command-line, UI support in Visual Studio is not there (yet)
  • I didn't verify uploading to the store at the time of writing
  • This was all done from a Mac, I need to find out if remote building a Mac app from Windows is actually a thing

Description

I have been trying to see if publishing a macOS (Mac Catalyst) app through .NET MAUI works at the moment.

Unsigned App Distribution

If you do not want to sign your app and/or do not want to publish you app to the store, and want to distribute it differently, you can create an unsigned .app or .pkg file.

Create .app executable

The command that can be used is: dotnet build -f:net6.0-maccatalyst -c:Release

Note that the command is dotnet build as opposed to dotnet publish. The publish command isn't working at this time.

Create .pkg executable

The command that can be used is: dotnet build -f:net6.0-maccatalyst -c:Release /p:CreatePackage=true

Note that the command is dotnet build as opposed to dotnet publish. The publish command isn't working at this time.

Running the app

If you want to run unsigned apps on macOS there is a few things that are good to know.

  1. If you download a .app file from the internet it won't run. You will have to execute a command like: chmod +x MyApp.app/Contents/MacOS/MyApp, where MyApp is replaced with the actual app name. This will make the app executable. When double-clicked on macOS, it will only show you a warning and still not run. Right-click and choose Open. Another dialog will appear, this dialog has an Open button. Subsequent runs of the app (also through double-click) won't show the warning again.
  2. There is something interesting about the .pkg file if you use it on your dev machine. If the .app is next to the .pkg file in the build artifacts and you install the .pkg, it will replace the .app file that is next to it. Even more so; if you move the .pkg file to elsewhere and run it, it still replaces the .app file in the build artifacts. Those are somehow linked. To be really sure the .pkg installs in your Applications folder, copy the .pkg file to outside of your build artifacts folder, delete the bin and obj folder and make sure that also deletes the .app file. The .pkg should now install correctly. This is a feature/bug from Apple.
  3. When distributing the .pkg file you will encounter similar dialogs as described at bullet 1 above. Also here, right-click and click Open to go around it.

Signed App Distribution

If you want to distribute your app through the App Store, you will have to sign your app. Here you will find how to do that.

{WIP}

Creating a Universal Binary

When you want your app to run on both M1 Mac hardware (without Rosetta emulation) and pre-M1 hardware, you will want to create a so-called universal binary.

To do this, add both the runtime identifiers for both platforms in your csproj file.

<PropertyGroup  Condition="'$(TargetFramework)' == 'net6.0-maccatalyst' and '$(Configuration)' == 'Release'">
    <!-- for Mac Catalyst -->
    <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>
</PropertyGroup>

Just for completeness, you can do the same for iOS and "regular" macOS apps by using the runtime identifiers below:

<!-- for macOS -->
<RuntimeIdentifiers>osx-x64;osx-arm64</RuntimeIdentifiers>
<!-- for iOS -->
<RuntimeIdentifiers>ios-arm;ios-arm64</RuntimeIdentifiers>

Related Resources

Also See

@xperiandri
Copy link

xperiandri commented Mar 27, 2022

With dotnet publish -f net6.0-macos -r osx-x64 -c Release /p:_PlatformName=macOS --self-contained on RC1 still

/usr/local/share/dotnet/packs/Microsoft.macOS.Sdk/12.1.303-rc.1.55/targets/Xamarin.Shared.Sdk.targets(1411,3): warning : The file '/Users/xperiandri/.nuget/packages/fsharp.core/6.0.3/contentFiles/any/netstandard2.1/FSharp.Core.xml' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/xperiandri/Projects/ITM/Client/Client.Mobile/Transmission.Client.Mobile.csproj]
/usr/local/share/dotnet/packs/Microsoft.macOS.Sdk/12.1.303-rc.1.55/targets/Xamarin.Shared.Sdk.targets(1411,3): warning : The file '/Users/xperiandri/Projects/ITM/Client/Client/bin/Release/netstandard2.0/Transmission.Client.Programs.xml' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/xperiandri/Projects/ITM/Client/Client.Mobile/Transmission.Client.Mobile.csproj]
/usr/local/share/dotnet/packs/Microsoft.macOS.Sdk/12.1.303-rc.1.55/targets/Xamarin.Shared.Sdk.targets(1411,3): warning : The file '/Users/xperiandri/Projects/ITM/Shared/Domain/bin/Release/netstandard2.0/Transmission.Domain.xml' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/xperiandri/Projects/ITM/Client/Client.Mobile/Transmission.Client.Mobile.csproj]
/usr/local/share/dotnet/packs/Microsoft.macOS.Sdk/12.1.303-rc.1.55/targets/Xamarin.Shared.Sdk.targets(1411,3): warning : The file '/Users/xperiandri/Projects/ITM/Shared/FSharp/bin/Release/netstandard2.0/Transmission.FSharp.xml' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/xperiandri/Projects/ITM/Client/Client.Mobile/Transmission.Client.Mobile.csproj]
  Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
productbuild : error : directory "bin/Release/net6.0-macos/osx-x64/publish" does not exist for writing "Transmission.Client.Mobile-1.0.pkg". [/Users/xperiandri/Projects/ITM/Client/Client.Mobile/Transmission.Client.Mobile.csproj]

productbuild : error : directory "bin/Release/net6.0-macos/osx-x64/publish" does not exist for writing "Transmission.Client.Mobile-1.0.pkg".

Binary log

@TanayParikh
Copy link
Contributor

@xperiandri we were running into this issue as well. Please upgrade to the latest MacOS version (12.3.*), that resolved the issue for us.

@jfversluis should we add instructions to move the .pkg to the Desktop and delete bin/obj folders, if the user is trying to install the published packaged on their machine?

@jfversluis
Copy link
Member Author

Updated the description, thanks!

@xperiandri
Copy link

@TanayParikh I still have the same issue after the macOS and XCode update. What else have you changed?

@TanayParikh
Copy link
Contributor

@TanayParikh I still have the same issue after the macOS and XCode update. What else have you changed?

Just realized you're using the dotnet publish command. Please try the dotnet build commands in the original post.

@xperiandri
Copy link

xperiandri commented Apr 13, 2022

xperiandri@Andrii-Mac Client.Mobile % dotnet build -f net6.0-macos -c Release /p:_PlatformName=macOS --no-restore /p:CreatePackage=true
Microsoft (R) Build Engine version 17.2.0-preview-22126-01+40f49cd8d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  Detected signing identity:
          
    Bundle Id: 
    App Id: 
/usr/local/share/dotnet/sdk/6.0.300-preview.22154.4/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file '/Users/xperiandri/Projects/ITM/Client/Client.Mobile/obj/project.assets.json' doesn't have a target for 'net6.0-macos/osx-x64'. Ensure that restore has run and that you have included 'net6.0-macos' in the TargetFrameworks for your project. You may also need to include 'osx-x64' in your project's RuntimeIdentifiers. [/Users/xperiandri/Projects/ITM/Client/Client.Mobile/Transmission.Client.Mobile.csproj]

Build FAILED.

/usr/local/share/dotnet/sdk/6.0.300-preview.22154.4/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file '/Users/xperiandri/Projects/ITM/Client/Client.Mobile/obj/project.assets.json' doesn't have a target for 'net6.0-macos/osx-x64'. Ensure that restore has run and that you have included 'net6.0-macos' in the TargetFrameworks for your project. You may also need to include 'osx-x64' in your project's RuntimeIdentifiers. [/Users/xperiandri/Projects/ITM/Client/Client.Mobile/Transmission.Client.Mobile.csproj]
    0 Warning(s)
    1 Error(s)

@TanayParikh
Copy link
Contributor


xperiandri@Andrii-Mac Client.Mobile % dotnet build -f net6.0-macos -c Release /p:_PlatformName=macOS --no-restore /p:CreatePackage=true

Microsoft (R) Build Engine version 17.2.0-preview-22126-01+40f49cd8d for .NET

Copyright (C) Microsoft Corporation. All rights reserved.



  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview

  Detected signing identity:

          

    Bundle Id: 

    App Id: 

/usr/local/share/dotnet/sdk/6.0.300-preview.22154.4/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file '/Users/xperiandri/Projects/ITM/Client/Client.Mobile/obj/project.assets.json' doesn't have a target for 'net6.0-macos/osx-x64'. Ensure that restore has run and that you have included 'net6.0-macos' in the TargetFrameworks for your project. You may also need to include 'osx-x64' in your project's RuntimeIdentifiers. [/Users/xperiandri/Projects/ITM/Client/Client.Mobile/Transmission.Client.Mobile.csproj]



Build FAILED.



/usr/local/share/dotnet/sdk/6.0.300-preview.22154.4/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file '/Users/xperiandri/Projects/ITM/Client/Client.Mobile/obj/project.assets.json' doesn't have a target for 'net6.0-macos/osx-x64'. Ensure that restore has run and that you have included 'net6.0-macos' in the TargetFrameworks for your project. You may also need to include 'osx-x64' in your project's RuntimeIdentifiers. [/Users/xperiandri/Projects/ITM/Client/Client.Mobile/Transmission.Client.Mobile.csproj]

    0 Warning(s)

    1 Error(s)



That's still a different command from the one Gerald posted above...

@xperiandri
Copy link

Indeed dotnet build -f net6.0-macos -c Release --no-restore /p:CreatePackage=true produces a pkg
That is a good workaround however publish must work for .NET 6.0.300 release @jeffreyrivor

@emorell96
Copy link

How do you use entitlements with MacCatalyst? I tried adding an Entitlements.plist to the MacCatalyst folder and setting the signing stuff like in the iOS projects. The app was built but it fails on start up with:

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: @executable_path/../MonoBundle/libSystem.IO.Compression.Native.dylib
Referenced from: /Users/USER/*/OpenStockApp.app/Contents/MacOS/OpenStockApp
Reason: tried: '/usr/lib/libSystem.IO.Compression.Native.dylib' (no such file), (security policy does not allow @ path expansion)
(terminated at launch; ignore backtrace)

Application Specific Information:
Library not loaded: @executable_path/../MonoBundle/libSystem.IO.Compression.Native.dylib
Referenced from: /Users/enriquemorell/Projects/OpenStockApp/OpenStockApp/bin/Release/net6.0-maccatalyst/maccatalyst-x64/OpenStockApp.app/Contents/MacOS/OpenStockApp
Reason: tried: '/usr/lib/libSystem.IO.Compression.Native.dylib' (no such file), (security policy does not allow @ path expansion)

The entitlements file:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
  <array>
    <string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
  </array>
</dict>
</plist>

@emorell96
Copy link

I found a workaround for the above setting static linking:

<_LibMonoLinkMode>Static</_LibMonoLinkMode>
<_LibXamarinLinkMode>Static</_LibXamarinLinkMode>

From:
xamarin/xamarin-macios#14686 (comment)

@JaneConan
Copy link

Indeed dotnet build -f net6.0-macos -c Release --no-restore /p:CreatePackage=true produces a pkg That is a good workaround however publish must work for .NET 6.0.300 release @jeffreyrivor

image

Unfortunately, my attempt here was unsuccessful.

The tip says dotnet workload restore needs to be performed,

image

but it doesn't work ~

Just like our said, we just want to release a Mac app or pkg installation package on Windows, but it's not so smooth~

@jfversluis
Copy link
Member Author

@JaneConan building your macOS app on Windows is not something that is supported, so that is expected.

@anpin
Copy link

anpin commented Jul 1, 2022

does it support compiling arm64 target on a x64 machine? I'm seeing following error

/usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/15.4.311/targets/Xamarin.Shared.Sdk.targets(1000,3): error : Failed to AOT compile SomeNet6Dependecy.dll, the AOT compiler exited with code 139

@changguangyu
Copy link

How to create signed Mac App for Mac App Store?

@angelru
Copy link

angelru commented Oct 20, 2022

how to sign and send to notary to distribute outside of Mac AppStore?
I'm having problems

https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution

when I submit a Mac Catalyst app, I don't have the option to validate/distribute in xcode

@angelru
Copy link

angelru commented Oct 21, 2022

@changguangyu

1. Signing the Installer:

productsign --sign "Developer ID Installer: Your Apple Account Name (**********)" ~/Desktop/example.pkg ~/Desktop/signed-example.pkg

2. Sending the notarization request:

Sign in to apps with your Apple ID using app-specific passwords:
https://support.apple.com/en-us/HT204397

xcrun altool --notarize-app --primary-bundle-id "id" --username "AppleID@mail.com" --password "cvbs-epfg-sizx-olwd" --file "signed-example.pkg"

you get back something like:

altool[8788:92462] No errors uploading 'signed-example.pkg'.
RequestUUID = 181638fb-a618-2298-bff0-470979f01326

3. Checking the notarization status:
xcrun altool --notarization-info 181638fb-a618-2298-bff0-470979f01326 --username "AppleID@mail.com" --password "cvbs-epfg-sizx-olwd"

5. Stapling the ticket to the file
xcrun stapler staple "signed-example.pkg"

stapling details with:
stapler validate --verbose "signed-example.pkg"

@angelru
Copy link

angelru commented Oct 21, 2022

https://developercommunity.visualstudio.com/t/Signed-NET-MAUI-MACCATALYST-/10178897

@angelru
Copy link

angelru commented Oct 23, 2022

After adding this to my csproj the app was notarized just fine.

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0-maccatalyst' and '$(Configuration)' == 'Release'">
		<!-- for Mac Catalyst -->
		<RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>
		<ProvisionType>Manual</ProvisionType>
		<EnableAssemblyILStripping>false</EnableAssemblyILStripping>
		<CodesignEntitlement>Entitlements.plist</CodesignEntitlement>
		<CodesignKey>CERTIFICATE</CodesignKey>
		<CodesignProvision>PROFILE</CodesignProvision>
		<UseHardenedRuntime>true</UseHardenedRuntime>
	</PropertyGroup>

@angelru
Copy link

angelru commented Nov 16, 2022

I still can't build/sign a maccatalyst app for outside of the apple store. So that the malicious software warning does not appear when executing

@datvm
Copy link

datvm commented Dec 1, 2022

I keep getting code sign error at verifying target _CodesignVerify.

    Target _CodesignVerify:
        /usr/bin/codesign --verify -vvvv "-R=anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)" bin/Release/net7.0-maccatalyst/PdfMerge.app 
        bin/Release/net7.0-maccatalyst/PdfMerge.app: valid on disk
        bin/Release/net7.0-maccatalyst/PdfMerge.app: satisfies its Designated Requirement
        test-requirement: code failed to satisfy specified code requirement(s)
        /usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/15.4.2372/tools/msbuild/iOS/Xamarin.Shared.targets(1929,3): error MSB6006: "codesign" exited with code 3.
    Done building target "_CodesignVerify" in project "PdfMerge.csproj" -- FAILED.

I thought it's due to wrong Entitlements.plist file but even when removing it, the same error happens. Please advise a fix. Thanks!

@Redth Redth added this to the Backlog milestone Dec 2, 2022
@ghost
Copy link

ghost commented Dec 2, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@rstolpe
Copy link

rstolpe commented Jan 5, 2023

Can someone write a good guide how to create certs etc from Apple to sign mac catalyst apps for uploading to AppStore? I can't figure it out, I have iOS version working just fine but the mac catalyst don't work at all and I'm starting to get frustrated about it.
I can only run it /debug it in x64 also aldo I'm on a M1 Pro machine.

@samhouts samhouts added the partner/macios Issues for the Mac / iOS SDK label Jan 6, 2023
@angelru
Copy link

angelru commented Jan 6, 2023

¿Alguien puede escribir una buena guía sobre cómo crear certificados, etc. de Apple para firmar aplicaciones de catalizador de Mac para cargarlas en AppStore? No puedo resolverlo, tengo la versión de iOS funcionando bien, pero el catalizador de Mac no funciona en absoluto y estoy empezando a sentirme frustrado por eso. Solo puedo ejecutarlo/depurarlo en x64 y también estoy en una máquina M1 Pro.

https://developercommunity.visualstudio.com/t/Signed-NET-MAUI-MACCATALYST-/10178897
#5399 (comment)
#5399 (comment)

Try to see if it works for you.

@rstolpe
Copy link

rstolpe commented Jan 7, 2023

I still can't build/sign a maccatalyst app for outside of the apple store. So that the malicious software warning does not appear when executing

Can you upload to apple store? Mac ?

I can't manage to do so with net7 and latest maui.

I press release in visual studio 2022 the trying to upload it with transporter but no luck.

How do you do?

@datvm
Copy link

datvm commented Jan 8, 2023

I still can't build/sign a maccatalyst app for outside of the apple store. So that the malicious software warning does not appear when executing

Can you upload to apple store? Mac ?

I can't manage to do so with net7 and latest maui.

I press release in visual studio 2022 the trying to upload it with transporter but no luck.

How do you do?

Me too. I couldn't even get the Remote to work so I just use VS Mac on Mac. I tried different types of certificates and provisional profiles but it either fail at building (when I include the Entitlements.plist file, see the error in my comment above) or I cannot pass the Transporter validation at all.

A step-by-step guide in both VS for Windows and for Mac would be appreciated.

@rstolpe
Copy link

rstolpe commented Jan 8, 2023

I still can't build/sign a maccatalyst app for outside of the apple store. So that the malicious software warning does not appear when executing

Can you upload to apple store? Mac ?

I can't manage to do so with net7 and latest maui.

I press release in visual studio 2022 the trying to upload it with transporter but no luck.

How do you do?

Me too. I couldn't even get the Remote to work so I just use VS Mac on Mac. I tried different types of certificates and provisional profiles but it either fail at building (when I include the Entitlements.plist file, see the error in my comment above) or I cannot pass the Transporter validation at all.

A step-by-step guide in both VS for Windows and for Mac would be appreciated.

Ok, I see. I'm also on Mac.
It seems like that MAUI just focused on iOS/iPadOS then forgot about macOS. It's too bad, I did really wanted to try Maui out in production.

@rstolpe
Copy link

rstolpe commented Jan 8, 2023

Got this figured out now, it's a lot of bugs that will trough you false positiv things etc.

Have a guide ready tomorrow, I been asking in an other issue after the doc repo so I can upload it there.

If they don't answer until tomorrow I'll publish it here as a issue our similar so can they use it later on if they need to

@rstolpe
Copy link

rstolpe commented Jan 9, 2023

Uploaded the guide in a Feature request.
dotnet/docs-maui#1187

If you have any Q just ask in that issue and I'll answer it.

@angelru
Copy link

angelru commented Jan 9, 2023

Cargó la guía en una solicitud de función. dotnet/docs-maui#1187

Si tienes alguna Q solo pregunta en ese tema y te la responde.

thanks, and if I want to distribute outside the AppStore? I think you need to do what I put above.

@rstolpe
Copy link

rstolpe commented Jan 9, 2023

Cargó la guía en una solicitud de función. dotnet/docs-maui#1187
Si tienes alguna Q solo pregunta en ese tema y te la responde.

thanks, and if I want to distribute outside the AppStore? I think you need to do what I put above.

Change the release part in the project file to something like this:

	<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Release'">
		<MtouchLink>Full</MtouchLink>
		<RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>
		<EnableCodeSigning>False</EnableCodeSigning>
		<ProvisionType>Manual</ProvisionType>
		<CreatePackage>true</CreatePackage>
		<EnablePackageSigning>true</EnablePackageSigning>
		<CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
		<CodesignKey>Apple Distribution: YOURNAME (*******)</CodesignKey>
		<CodesignProvision>YOUR PROFILE NAME</CodesignProvision>
		<PackageSigningKey>3rd Party Mac Developer Installer: YOURNAME (*******)</PackageSigningKey>
		<UseHardenedRuntime>true</UseHardenedRuntime>
	</PropertyGroup>

And change the following line from Entitlements to what I'm pasting below.

		<key>com.apple.security.app-sandbox</key>
		<false/>
		<key>com.apple.security.network.client</key>
		<false/>

Then past the .pkg file to any other folder then the bin / release folder, delete the bin folder then you can install the software.
The software seem to be somehow attached to the bin folders things don't know why and that's why you need to delete that folder to get a proper result after you have installed the software.

@angelru
Copy link

angelru commented Jan 9, 2023

Cargó la guía en una solicitud de función. dotnet/docs-maui#1187
Si tienes alguna Q solo pregunta en ese tema y te la responde.

gracias, y si quiero distribuir fuera de la AppStore? Creo que tienes que hacer lo que puse arriba.

Cambie la parte de lanzamiento en el archivo del proyecto a algo como esto:

	<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Release'">
		<MtouchLink>Full</MtouchLink>
		<RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>
		<EnableCodeSigning>False</EnableCodeSigning>
		<ProvisionType>Manual</ProvisionType>
		<CreatePackage>true</CreatePackage>
		<EnablePackageSigning>true</EnablePackageSigning>
		<CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
		<CodesignKey>Apple Distribution: YOURNAME (*******)</CodesignKey>
		<CodesignProvision>YOUR PROFILE NAME</CodesignProvision>
		<PackageSigningKey>3rd Party Mac Developer Installer: YOURNAME (*******)</PackageSigningKey>
		<UseHardenedRuntime>true</UseHardenedRuntime>
	</PropertyGroup>

Y cambie la siguiente línea de Derechos a lo que estoy pegando a continuación.

		<key>com.apple.security.app-sandbox</key>
		<false/>
		<key>com.apple.security.network.client</key>
		<false/>

Luego, pase el archivo .pkg a cualquier otra carpeta, luego a la carpeta bin / release, elimine la carpeta bin y luego podrá instalar el software. El software parece estar de alguna manera adjunto a las carpetas bin, no sé por qué y es por eso que necesita eliminar esa carpeta para obtener un resultado adecuado después de haber instalado el software.

but the warning that the developer is not trustworthy will come out? that is, the application must be notarized.

@rstolpe
Copy link

rstolpe commented Jan 9, 2023

Cargó la guía en una solicitud de función. dotnet/docs-maui#1187
Si tienes alguna Q solo pregunta en ese tema y te la responde.

gracias, y si quiero distribuir fuera de la AppStore? Creo que tienes que hacer lo que puse arriba.

Cambie la parte de lanzamiento en el archivo del proyecto a algo como esto:

	<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Release'">
		<MtouchLink>Full</MtouchLink>
		<RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>
		<EnableCodeSigning>False</EnableCodeSigning>
		<ProvisionType>Manual</ProvisionType>
		<CreatePackage>true</CreatePackage>
		<EnablePackageSigning>true</EnablePackageSigning>
		<CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
		<CodesignKey>Apple Distribution: YOURNAME (*******)</CodesignKey>
		<CodesignProvision>YOUR PROFILE NAME</CodesignProvision>
		<PackageSigningKey>3rd Party Mac Developer Installer: YOURNAME (*******)</PackageSigningKey>
		<UseHardenedRuntime>true</UseHardenedRuntime>
	</PropertyGroup>

Y cambie la siguiente línea de Derechos a lo que estoy pegando a continuación.

		<key>com.apple.security.app-sandbox</key>
		<false/>
		<key>com.apple.security.network.client</key>
		<false/>

Luego, pase el archivo .pkg a cualquier otra carpeta, luego a la carpeta bin / release, elimine la carpeta bin y luego podrá instalar el software. El software parece estar de alguna manera adjunto a las carpetas bin, no sé por qué y es por eso que necesita eliminar esa carpeta para obtener un resultado adecuado después de haber instalado el software.

but the warning that the developer is not trustworthy will come out? that is, the application must be notarized.

Have you tried to change <EnableCodeSigning>False</EnableCodeSigning>to true?
Then change place for the .pkg file and delete obj and bin folders.

@igalfsg
Copy link

igalfsg commented Feb 7, 2023

Is signing for MacOS now supported?

@rstolpe
Copy link

rstolpe commented Feb 7, 2023

Is signing for MacOS now supported?

yes, check out the guide that I did here:
dotnet/docs-maui#1187

@headintheclouds21
Copy link

Great info here. Does this work for signing and notarizing for distribution outside of the store as well?

@davidbritch
Copy link
Contributor

To publish for distribution outside the App Store, you need a Developer ID certificate, and a Developer ID Installer cert. Then publish with:

dotnet publish -f:net7.0-maccatalyst -c:Release /p:MtouchLink=SdkOnly /p:CreatePackage=true /p:EnableCodeSigning=true /p:EnablePackageSigning=true /p:CodesignKey="Developer ID Application: CERT NAME GOES HERE" /p:CodesignProvision="PROFILE NAME GOES HERE" /p:CodesignEntitlements="Platforms\MacCatalyst\Entitlements.plist" /p:PackageSigningKey="Developer ID Installer: CERT NAME GOES HERE" /p:UseHardenedRuntime=true

The point is that code signing must be enabled. The problem is that the _CodesignVerify build target will fail - I'll be logging a bug for this (note that the code signing will succeed, providing your certs/profile are right, it's just the verification of the code signing that fails). So add the following to your .csproj to skip the _CodesignVerify build target:

	<Target Name="_SkipCodesignVerify" BeforeTargets="_CodesignVerify" AfterTargets="_CodesignAppBundle">  
		<PropertyGroup>    
			<_RequireCodeSigning>false</_RequireCodeSigning>  
		</PropertyGroup>
	</Target>

Then you can notarize:

xcrun notarytool submit filename.pkg --apple-id APPLE_ID_GOES_HERE --password APP_SPECIFIC_PASSWORD_GOES_HERE --team-id TEAM_ID_GOES_HERE --wait

Then staple the ticket:

xcrun stapler staple filename.pkg

@angelru
Copy link

angelru commented Mar 18, 2023

To publish for distribution outside the App Store, you need a Developer ID certificate, and a Developer ID Installer cert. Then publish with:

dotnet publish -f:net7.0-maccatalyst -c:Release /p:MtouchLink=SdkOnly /p:CreatePackage=true /p:EnableCodeSigning=true /p:EnablePackageSigning=true /p:CodesignKey="Developer ID Application: CERT NAME GOES HERE" /p:CodesignProvision="PROFILE NAME GOES HERE" /p:CodesignEntitlements="Platforms\MacCatalyst\Entitlements.plist" /p:PackageSigningKey="Developer ID Installer: CERT NAME GOES HERE" /p:UseHardenedRuntime=true

The point is that code signing must be enabled. The problem is that the _CodesignVerify build target will fail - I'll be logging a bug for this (note that the code signing will succeed, providing your certs/profile are right, it's just the verification of the code signing that fails). So add the following to your .csproj to skip the _CodesignVerify build target:

	<Target Name="_SkipCodesignVerify" BeforeTargets="_CodesignVerify" AfterTargets="_CodesignAppBundle">  
		<PropertyGroup>    
			<_RequireCodeSigning>false</_RequireCodeSigning>  
		</PropertyGroup>
	</Target>

Then you can notarize:

xcrun notarytool submit filename.pkg --apple-id APPLE_ID_GOES_HERE --password APP_SPECIFIC_PASSWORD_GOES_HERE --team-id TEAM_ID_GOES_HERE --wait

Then staple the ticket:

xcrun stapler staple filename.pkg

Will it be added to the documentation?

@davidbritch
Copy link
Contributor

@angelru Yes, it's in-progress.

@jfversluis
Copy link
Member Author

Alright, closing this one for now. The official docs are on there way, you can find a quick overview of those here: https://github.com/dotnet/docs-maui/issues?q=is%3Aissue+is%3Aopen+Publish+Mac+Catalyst+

They should be here soon! And with that there is nothing much that we can do for this on this repo. Thanks everyone!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) partner/macios Issues for the Mac / iOS SDK platform/macOS 🍏 macOS / Mac Catalyst s/triaged Issue has been reviewed
Projects
None yet
Development

No branches or pull requests