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

_CodesignVerify target fails when publishing a .NET MAUI MacCat app for outside the App Store #17829

Closed
davidbritch opened this issue Mar 16, 2023 · 0 comments · Fixed by #17835
Labels
bug If an issue is a bug or a pull request a bug fix
Milestone

Comments

@davidbritch
Copy link

Publishing a .NET MAUI Mac Catalyst app for distribution outside the App Store requires a Developer ID Application certificate, and a Developer ID Installer certificate (+ App ID and provisioning profile). Then you can publish your app using:

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: MY CERT DETAILS" /p:CodesignProvision="MY PROFILE NAME" /p:CodesignEntitlements="Platforms\MacCatalyst\Entitlements.plist" /p:PackageSigningKey="Developer ID Installer: MY CERT DETAILS" /p:UseHardenedRuntime=true

However, this results in an error telling you that codesign has exited with code 3:

/usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/16.2.1040/tools/msbuild/iOS/Xamarin.Shared.targets(1930,3): error MSB6006: "codesign" exited with code 3. [/Users/davidbritch/Projects/MyMauiApp/MyMauiApp/MyMauiApp.csproj::TargetFramework=net7.0-maccatalyst]

Examining the bin log shows that the _CodesignVerify target fails with:

test-requirement: code failed to satisfy specified code requirement(s)

After chatting to @rolfbjarne, the workaround is to disable the _CodesignVerify target in your .csproj:

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

This enables the signed .pkg to be produced, which I was then able to notarize using xcrun notarytool.

Steps to Reproduce

  1. Create a new .NET MAUI app.
  2. Create required certs, app ID, and provisioning profile in your Apple Developer Account.
  3. Install certs into Keychain Access.
  4. Sync your Apple Developer Account in Xcode.
  5. Publish the app on Mac Cat, for distribution outside the App Store, using the CLI command listed above.

Expected Behavior

App publishes and signed .pkg is produced.

Actual Behavior

Error: /usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/16.2.1040/tools/msbuild/iOS/Xamarin.Shared.targets(1930,3): error MSB6006: "codesign" exited with code 3. [/Users/davidbritch/Projects/MyMauiApp/MyMauiApp/MyMauiApp.csproj::TargetFramework=net7.0-maccatalyst]

No .pkg is produced.

Environment

.NET 7 installed by VSMac, although this is a publishing issue using CLI.

Version information
Visual Studio Enterprise 2022 for Mac
Version 17.5.2 (build 14)
Installation UUID: a31562fc-b80d-45d9-b1be-4f4061f873e1

Runtime
.NET 7.0.1 (64-bit)
Architecture: X64
Microsoft.macOS.Sdk 12.3.2372; git-rev-head:754abbf6a3563f6267e5717ae832b4ac25b1f2fb; git-branch:release/7.0.1xx-xcode13.3

Roslyn (Language Service)
6.5.0-3.23056.2+97881342e427ff5cdcba8f12b12ff8e6f3564431

NuGet
Version: 6.4.0.117

.NET SDK (x64)
SDK: /usr/local/share/dotnet/sdk/7.0.202/Sdks
SDK Versions:
	7.0.202
	7.0.201
	7.0.200
	7.0.103
	7.0.102
	7.0.101
	7.0.100
	7.0.100-rc.2.22477.23
	7.0.407
	6.0.406
	6.0.405
	6.0.404
	6.0.403
	6.0.402
	6.0.401
	6.0.400
	5.1.426
	4.1.425
	3.1.424
	3.1.423
	3.1.422
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	8.0.4
	7.0.3
	7.0.2
	7.0.1
	6.0.15
	6.0.14
	6.0.13
	6.0.12
	6.0.11
	6.0.10
	6.0.9
	6.0.8
	3.1.32
	3.1.31
	3.1.30
	3.1.29
	3.1.28

Xamarin.Profiler
Version: 1.8.0.49
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode: 14.2 21534
Build: 14C18

Xamarin.Mac
Not Installed

Xamarin Designer
Version: 17.5.3.47
Hash: e8b5d371c3
Branch: remotes/origin/d17-5
Build date: 2023-03-09 19:57:52 UTC

Xamarin.iOS
Version: 16.2.0.5 Visual Studio Enterprise
Hash: 7738c90c9
Branch: xcode14.2
Build date: 2023-01-25 15:56:15-0500

Xamarin.Android
Version: 13.2.0.0 (Visual Studio Enterprise)
Commit: xamarin-android/d17-5/797e2e1
Android SDK: /Users/davidbritch/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		12.0 (API level 31)
		13.0 (API level 33)

SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 34.0.1
SDK Build Tools Version: 33.0.0

Build Information: 
Mono: 6dd9def
Java.Interop: xamarin/java.interop/main@149d70fe
SQLite: xamarin/sqlite/3.40.0@fdc1e34
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@9f02d77

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.16.1
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.5.0.33
Hash: f0c0c52
Branch: remotes/origin/d17-5~2
Build date: 2023-03-09 19:57:57 UTC

Android Device Manager
Version: 0.0.0.1245
Hash: 7f8a990
Branch: 7f8a990
Build date: 2023-03-09 19:57:57 UTC

Build Information
Release ID: 1705020014
Git revision: f95e127ba5837148420d81c7c14c47ca8eade102
Build date: 2023-03-09 19:56:01+00
Build branch: release-17.5
Build lane: release-17.5

Operating System
Mac OS X 12.6.3
Darwin 21.6.0 Darwin Kernel Version 21.6.0
    Mon Dec 19 20:44:01 PST 2022
    root:xnu-8020.240.18~2/RELEASE_X86_64 x86_64

Build Logs

msbuild.log

@rolfbjarne rolfbjarne added this to the .NET 8 milestone Mar 17, 2023
@rolfbjarne rolfbjarne added the bug If an issue is a bug or a pull request a bug fix label Mar 17, 2023
@rolfbjarne rolfbjarne added this to Bugs in .NET 8 - Themes Mar 17, 2023
rolfbjarne added a commit to rolfbjarne/SubmissionSamples that referenced this issue Mar 17, 2023
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Mar 17, 2023
…amarin#17829.

* For Mac Catalyst apps we must verify the code signature like we do it for
  macOS apps. Fixes xamarin#17829.
* Enable nullability and fix code accordingly.
* Merge the CodesignVerify and CodesignVerifyTaskBase classes to simplify the
  code.

Submission test is added as well:

* xamarin/maccore#2656
* xamarin/SubmissionSamples#51

Fixes xamarin#17829.
rolfbjarne added a commit to xamarin/SubmissionSamples that referenced this issue Mar 21, 2023
.NET 8 - Themes automation moved this from Bugs to Done Mar 21, 2023
rolfbjarne added a commit that referenced this issue Mar 21, 2023
…17829. (#17835)

* For Mac Catalyst apps we must verify the code signature like we do it for macOS apps. Fixes #17829.
* Enable nullability and fix code accordingly.
* Merge the CodesignVerify and CodesignVerifyTaskBase classes to simplify the code.

Submission test is added as well:

* xamarin/maccore#2656
* xamarin/SubmissionSamples#51

Fixes #17829.
vs-mobiletools-engineering-service2 pushed a commit to vs-mobiletools-engineering-service2/xamarin-macios that referenced this issue Mar 21, 2023
…amarin#17829.

* For Mac Catalyst apps we must verify the code signature like we do it for
  macOS apps. Fixes xamarin#17829.
* Enable nullability and fix code accordingly.
* Merge the CodesignVerify and CodesignVerifyTaskBase classes to simplify the
  code.

Submission test is added as well:

* xamarin/maccore#2656
* xamarin/SubmissionSamples#51

Fixes xamarin#17829.
vs-mobiletools-engineering-service2 pushed a commit to vs-mobiletools-engineering-service2/xamarin-macios that referenced this issue Mar 21, 2023
…amarin#17829.

* For Mac Catalyst apps we must verify the code signature like we do it for
  macOS apps. Fixes xamarin#17829.
* Enable nullability and fix code accordingly.
* Merge the CodesignVerify and CodesignVerifyTaskBase classes to simplify the
  code.

Submission test is added as well:

* xamarin/maccore#2656
* xamarin/SubmissionSamples#51

Fixes xamarin#17829.
vs-mobiletools-engineering-service2 pushed a commit to vs-mobiletools-engineering-service2/xamarin-macios that referenced this issue Mar 21, 2023
…amarin#17829.

* For Mac Catalyst apps we must verify the code signature like we do it for
  macOS apps. Fixes xamarin#17829.
* Enable nullability and fix code accordingly.
* Merge the CodesignVerify and CodesignVerifyTaskBase classes to simplify the
  code.

Submission test is added as well:

* xamarin/maccore#2656
* xamarin/SubmissionSamples#51

Fixes xamarin#17829.
rolfbjarne added a commit that referenced this issue Mar 22, 2023
…e verify macOS apps. Fixes #17829. (#17868)

* For Mac Catalyst apps we must verify the code signature like we do it for
  macOS apps. Fixes #17829.
* Enable nullability and fix code accordingly.
* Merge the CodesignVerify and CodesignVerifyTaskBase classes to simplify the
  code.

Submission test is added as well:

* xamarin/maccore#2656
* xamarin/SubmissionSamples#51

Fixes #17829.

Backport of #17835

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
rolfbjarne pushed a commit that referenced this issue Mar 22, 2023
…acOS apps. Fixes #17829. (#17867)

* For Mac Catalyst apps we must verify the code signature like we do it for
  macOS apps. Fixes #17829.
* Enable nullability and fix code accordingly.
* Merge the CodesignVerify and CodesignVerifyTaskBase classes to simplify the
  code.

Submission test is added as well:

* xamarin/maccore#2656
* xamarin/SubmissionSamples#51

Fixes #17829.


Backport of #17835
rolfbjarne pushed a commit that referenced this issue Mar 22, 2023
…e verify macOS apps. Fixes #17829. (#17869)

* For Mac Catalyst apps we must verify the code signature like we do it for
  macOS apps. Fixes #17829.
* Enable nullability and fix code accordingly.
* Merge the CodesignVerify and CodesignVerifyTaskBase classes to simplify the
  code.

Submission test is added as well:

* xamarin/maccore#2656
* xamarin/SubmissionSamples#51

Fixes #17829.

Backport of #17835
@ghost ghost locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix
Projects
No open projects
2 participants