Why is Microsoft.CSharp.dll not signed using VS Mac?
If building a solution targeting an iPhone directly on a Mac or remotely via the Mac from a PC, the following errors are encountered. However, building the same code directly to the iPhone, it succeeds. Both VS's are latest versions with latest updates. Why is codesign not working?
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1040/tools/msbuild/iOS/Xamarin.Shared.targets(3,3): Error: /usr/bin/codesign exited with code 1:
/Volumes/Mac HD - Data/Projects/Sentry/Sentry/bin/Debug/net7.0-ios/ios-arm64/Sentry.app: code object is not signed at all
In subcomponent: /Volumes/Mac HD - Data/Projects/Sentry/Sentry/bin/Debug/net7.0-ios/ios-arm64/Sentry.app/Microsoft.CSharp.dll (Sentry)
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.2.1040/tools/msbuild/iOS/Xamarin.Shared.targets(3,3): Error: Failed to codesign '/Volumes/Mac HD - Data/Projects/Sentry/Sentry/bin/Debug/net7.0-ios/ios-arm64/Sentry.app': /Volumes/Mac HD - Data/Projects/Sentry/Sentry/bin/Debug/net7.0-ios/ios-arm64/Sentry.app: code object is not signed at all
In subcomponent: /Volumes/Mac HD - Data/Projects/Sentry/Sentry/bin/Debug/net7.0-ios/ios-arm64/Sentry.app/Microsoft.CSharp.dll
Visual Studio
.NET MAUI
C#
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,221 Reputation points • Microsoft Vendor
2023-03-31T08:17:10.5566667+00:00 May I ask what's the mean of "building the same code directly to the iPhone"? Does it mean you configure Hot Restart and connect your iPhone with your Windows machine? And the code signing issue only occurs when pairing to mac or using VS-for-Mac, right? Would you mind sharing the OS version of your Mac the Xcode version, and iOS version of your iPhone?
In addition, you could try to go to Properties -> iOS->Bundle Signing window, then check if you can select a Signing Identity, and a corresponding Development Provisioning profile. If so, you can run and test again.
If not, you can open Xcode, create a new project whose Bundle Identifier should be same as your MAUI project, then choose Automatically manage signing, and run the native iOS project on your iPhone.(Xcode->your project->Signing&Capabilities->Automatically manage signing, Bundle Identifier option is located here as well.)
Then you can turn to VS, select a Signing Identity and a corresponding Provisioning profile, then check if the code sign issue still exists. (Bundle Identifier is under Properties->Buid->Application ID with VS for mac, and is in Platform/iOS/Info.plist file with VS)
If you have any other issues, please feel free to post in here.
-
Marc George 171 Reputation points
2023-03-31T14:13:29.56+00:00 My primary IDE is a PC with the latest version of VS Pre, v16.1.2. The Mac has the latest version of VS also. I typically use the PC with the iPhone connected to deploy and debug with. Occasionally in the past I have used the Mac as the IDE successfully. I am not using Hot-Reload.
I encountered this problem initially trying to deploy to another iPhone to begin beta-testing following the current guidelines using a Mac pairing. I subsequently tried building and deploying using the Mac directly. Attempting to determine if the issue was related to the new phone, I attempted the procedures against the first phone with the same issue present. However, I was able to deploy to it from the PC.
I have verified the current Bundle Identifier and it allows that deployment to the first phone which has a completed device profile. However, since I can't deploy from the Mac, the second phone does not have its profile.
What is of interest to me is the fact that the problem is with the code signing of the CSharp.dll.
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,221 Reputation points • Microsoft Vendor
2023-04-03T09:59:22.6+00:00 If you connect your device with your windows machine, it means you are using hot restart.
You can check if the device is in Devices list at https://developer.apple.com/. And you could try to check if this new iPhone is included in the profile.
If you have any other issues, please feel free to post in here.
-
Marc George 171 Reputation points
2023-04-06T22:07:25.89+00:00 I don't have hot restart enabled, but I am able to deploy and debug on my initial iPhone. The new device is listed under my Apple developer account. Developer mode is enabled on the device. Today, in my attempt to it I encountered the error "A valid provisioning profile for this executable was not found."
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,221 Reputation points • Microsoft Vendor
2023-04-07T08:15:15.0533333+00:00 "A valid provisioning profile for this executable was not found." means there is not a matching development provisioning profile. You can refer to the official doc and create a new development provisioning profile manually: Manual provisioning for .NET MAUI iOS apps - .NET MAUI | Microsoft Learn
-
Marc George 171 Reputation points
2023-04-07T11:32:49.8366667+00:00 Thanks. With that said, I will try and follow the procedure in the link today. The limit does make testing more difficult across the various device models and OS versions. I will update you.
-
Marc George 171 Reputation points
2023-04-08T01:22:40.7+00:00 Following the procedure provided, which I have used before, the issue persists. I went as far as replacing both the certificate and profile in use. The build Output and logs are attached as a renamed Zip file, "Outputs.txt", in order to upload. Outputs.txt
My earlier response regarding Hot Restart not being in use was regarding Hot Reload. Hot Restart is in use.
However, it is interesting that the Hot Restart is greyed out in the screen shot. Note that status of the Certificate and Profile as valid.
Their statuses at Apple are also good.
During compilation they are detected.
-
Marc George 171 Reputation points
2023-04-08T13:32:17.2166667+00:00 Again, as the title stated, why isn't a build and deploy from the VS Mac capable when it is from VS Win?
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,221 Reputation points • Microsoft Vendor
2023-04-10T03:15:21.2833333+00:00 You said "Microsoft.CSharp.dll not signed using VS Mac" but the screen shot seems about Windows.
From the Apple Developer Account screenshot (second one), it means there is a valid certificate and a valid provisioning profile. But that doesn't mean they match each other. You can go to Properties->iOS->Bundle Signing, then select Manual Provisioning, and check if you can select a matching identity and provisioning profile.
why isn't a build and deploy from the VS Mac capable when it is from VS Win?
They are two different certificates. The Apple developer screenshot (third one) shows there is only one certificate for your profile. You could try to edit the provisioning profile at Apple developer portal (the location at third screen shot). And add a valid identity (both certificates from your Mac and Windows machine). If you have any other issues, please feel free to post here.
Understanding certificate key pairs :A developer profile contains certificates, their associated keys, and any provisioning profiles associated with the Apple developer account. There are two versions of a developer profile—one exists in Apple's developer portal, and the other lives on a local machine. The difference between the two is the type of keys they contain: the profile on Apple's developer portal contains all of the public keys associated with your certificates, while the copy on your local machine contains all of the private keys. For certificates to be valid, the key pairs must match. -
Marc George 171 Reputation points
2023-04-10T09:28:00.98+00:00 Just to be clear, I have to create different certificates and profiles for each machine and OS? If I add another Mac, then I have to repeat the process?
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,221 Reputation points • Microsoft Vendor
2023-04-11T01:48:12.87+00:00 Creating different certificates and profiles is a solution, you can also import the certificate into another Mac or Windows machine. This requires you export the p12 file from Keychain in your first Mac. Detailed Steps:
Open Keychain Access ->Login->Certificates>Expand the certificate so the associated private key is visible, right-click on the key and chose Export. (You will be prompted for a filename and a password) Transfer and save the file to another mac, then import the certificate:
Open Keychain Access ->File->Import Items->select the certificate that exported (enter the password). If you want to import this certificate into your Windows machine:
Open VS->Tools->Options->Xamarin->Apple Accounts->select your team->View details->Import Certificate After that, you can download the provisioning profile and double-click the profile to install into your Mac (For Windows machine, you can open VS->Tools->Options->Xamarin->Apple Accounts->select your team->View details->Download all profiles) Then you can select the matching certificate and provisioning profile in Properties->iOS->Bundle Signing-> Manual Provisioning
Sign in to comment