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

Unable to deploy only myApp to iOS device #16835

Closed
Varmod opened this issue Aug 17, 2023 · 17 comments
Closed

Unable to deploy only myApp to iOS device #16835

Varmod opened this issue Aug 17, 2023 · 17 comments
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-attention Issue has more information and needs another look s/no-repro Can no longer be reproduced on latest t/bug Something isn't working

Comments

@Varmod
Copy link

Varmod commented Aug 17, 2023

Description

I'm working on a app, and during development I've deployed to my device at least a 50 times. Then 4 days ago something broke and no matter what fix I've tried to apply I couldn't get it to work.

Normally I use the setup that I develop on my windows machine, and I have my iOS device connected to my Mac and deploy to remote device.

Then on the unfortunate day I've received a codesign error that it was unable to codesign one my assets a video. No problem, I removed it, and then a couple more untill codesign raised the stakes.

Severity	Code	Description	Project	File	Line	Suppression State
Error		Failed to codesign '/Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/.../bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app': /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/.../bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app: code object is not signed at all
In subcomponent: /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/.../bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app/Microsoft.CSharp.dll

        	MyApp C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.4.7089\tools\msbuild\iOS\Xamarin.Shared.targets	2163	

At first I thought no big deal, I've seen it a couple times I'll figure out some other way to fix it. But I failed.

I've tried to change the setup by connecting the iOS device to my windows machine and deploy locally. But I started receiving the following error take from xamarin logs:

, _iOSRuntimeIdentifier: ios-arm64, IsHotRestartBuild: True, IsHotRestartEnvironmentReady: True: 08/17/2023 18:51:22Z
    DateTime=2023-08-17T18:51:22.9213838Z: 08/17/2023 18:51:22Z
Xamarin.Messaging.IDB.Local.GetMobileDeviceConfigurationMessageHandler Information: 0 : Apple Support - iTunes installed: 'True', Installation type: 'Store': 08/17/2023 18:51:24Z
    DateTime=2023-08-17T18:51:24.5675470Z: 08/17/2023 18:51:24Z
Xamarin.iOS.Windows.Installer.ApplicationSession Information: 0 : Creating application ipa file: C:\Users\user\AppData\Local\Temp\Xamarin\HotRestart\Signing\MyApp.app\out\MyApp.ipa: 08/17/2023 18:51:24Z
    DateTime=2023-08-17T18:51:24.6470518Z: 08/17/2023 18:51:24Z
Xamarin.iOS.Windows.FileSystem.FileSession Information: 0 : Uploading file 'C:\Users\user\AppData\Local\Temp\Xamarin\HotRestart\Signing\MyApp.app\out\MyApp.ipa' to 'PublicStaging'...: 08/17/2023 18:51:44Z
    DateTime=2023-08-17T18:51:44.0267962Z: 08/17/2023 18:51:44Z
Xamarin.iOS.Windows.FileSystem.FileSession Information: 0 : Validating device directory 'PublicStaging'...: 08/17/2023 18:51:44Z
    DateTime=2023-08-17T18:51:44.0267962Z: 08/17/2023 18:51:44Z
Xamarin.iOS.Windows.FileSystem.FileSession Information: 0 : Creating file 'PublicStaging/com.company.myapp' in 'PublicStaging'...: 08/17/2023 18:51:44Z
    DateTime=2023-08-17T18:51:44.3650444Z: 08/17/2023 18:51:44Z
Xamarin.iOS.Windows.FileSystem.FileSession Information: 0 : Writing content to file 'PublicStaging/com.company.myapp'...: 08/17/2023 18:51:44Z
    DateTime=2023-08-17T18:51:44.9991406Z: 08/17/2023 18:51:44Z
Xamarin.iOS.Windows.HotRestartClient Error: 0 : Deploy Error: Could not write content to file 'PublicStaging/com.company.myapp': 08/17/2023 18:51:55Z
    DateTime=2023-08-17T18:51:55.1324473Z: 08/17/2023 18:51:55Z
Xamarin.Messaging.IDB.Local.DeployAppMessageHandler Error: 0 : An error occurred while trying to deploy the app 'MyApp.app'. Details: Could not write content to file 'PublicStaging/com.company.myapp'
Xamarin.iOS.Windows.WindowsiOSException: Could not write content to file 'PublicStaging/com.company.myapp'
   at Xamarin.iOS.Windows.FileSystem.FileSession.ExecuteAfcAction(Func`1 action, String message, String errorMessage) in D:\a\_work\1\s\src\Tools\Xamarin.iOS.Windows.Client\FileSystem\FileSession.cs:line 261
   at Xamarin.iOS.Windows.FileSystem.FileSession.CreateFile(AfcClientHandle afcClient, String deviceFolder, String fileName, Byte[] buffer) in D:\a\_work\1\s\src\Tools\Xamarin.iOS.Windows.Client\FileSystem\FileSession.cs:line 246
   at Xamarin.iOS.Windows.FileSystem.FileSession.UploadFile(AfcClientHandle afcClient, String deviceFolder, String file, String targetFileName) in D:\a\_work\1\s\src\Tools\Xamarin.iOS.Windows.Client\FileSystem\FileSession.cs:line 213
   at Xamarin.iOS.Windows.FileSystem.FileSession.UploadFileToPublicStaging(String filePath, String targetFileName) in D:\a\_work\1\s\src\Tools\Xamarin.iOS.Windows.Client\FileSystem\FileSession.cs:line 40
   at Xamarin.iOS.Windows.AppleDeviceExtensions.ExecuteWithSession(AppleDevice nativeDevice, Action action) in D:\a\_work\1\s\src\Tools\Xamarin.iOS.Windows.Client\Extensions\AppleDeviceExtensions.cs:line 14
   at Xamarin.iOS.Windows.Installer.ApplicationSession.Deploy(String appRootFolder, String appBundleId, String appName) in D:\a\_work\1\s\src\Tools\Xamarin.iOS.Windows.Client\Installer\ApplicationSession.cs:line 94
   at Xamarin.iOS.Windows.HotRestartClient.Deploy(AppleDevice nativeDevice, String appBundleId, String appBundleName, Boolean& incremental) in D:\a\_work\1\s\src\Tools\Xamarin.iOS.Windows.Client\HotRestartClient.cs:line 250
   at Xamarin.Messaging.IDB.Local.DeployAppMessageHandler.<ExecuteAsync>d__5.MoveNext() in D:\a\_work\1\s\src\Messaging\Xamarin.Messaging.IDB.Local\Handlers\DeployAppMessageHandler.cs:line 43: 08/17/2023 18:51:55Z
    DateTime=2023-08-17T18:51:55.1324473Z: 08/17/2023 18:51:55Z

As a sanity check I've decided to try deploying a blank Maui app with both approaches and both times it deployed smoothly.
Please help me.

I wanted to provide more information on the codesign failtures but I wasn't able to find any place where it's logged.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

7.0.92

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No.

Relevant log output

No response

@Varmod Varmod added the t/bug Something isn't working label Aug 17, 2023
@samhouts samhouts added area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging platform/iOS 🍎 area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) labels Aug 17, 2023
@samhouts
Copy link
Member

@emaf @mauroa ideas?

@emaf
Copy link
Contributor

emaf commented Aug 18, 2023

@Varmod I'd start by investigating the codesigning error for remote devices, because if the problems is around your signing identity/provisioning profile, it would also affect deploying to local devices.

We'll need a build binary log to investigate this problem. You can get one using the Project System Tools extension for Visual Studio. You can follow the steps decribed here.

Please record and share the binlog after reproducing the remote codesign problem.

Also looping @rolfbjarne in case he thinks we need anything else.

@Varmod
Copy link
Author

Varmod commented Aug 19, 2023

@emaf I only found the same information as I already posted

Severity	Code	Description	Project	File	Time
Message		/usr/bin/codesign exited with code 1:
/Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/a5aadbf6ab12cae6ebac45c234ae849bf5dd9082c02817162aed590f23a4073b/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app: code object is not signed at all
In subcomponent: /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/a5aadbf6ab12cae6ebac45c234ae849bf5dd9082c02817162aed590f23a4073b/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app/Microsoft.CSharp.dll			2023-08-19T08:32:47
Message		Tool /usr/bin/codesign execution finished (exit code = 1).
        			2023-08-19T08:32:47
Message		Task "Codesign"			2023-08-19T08:32:47
Message		/Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/a5aadbf6ab12cae6ebac45c234ae849bf5dd9082c02817162aed590f23a4073b/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app: code object is not signed at all
In subcomponent: /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/a5aadbf6ab12cae6ebac45c234ae849bf5dd9082c02817162aed590f23a4073b/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app/Microsoft.CSharp.dll
			2023-08-19T08:32:47
Message		Failed to codesign '/Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/a5aadbf6ab12cae6ebac45c234ae849bf5dd9082c02817162aed590f23a4073b/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app': /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/a5aadbf6ab12cae6ebac45c234ae849bf5dd9082c02817162aed590f23a4073b/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app: code object is not signed at all
In subcomponent: /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/a5aadbf6ab12cae6ebac45c234ae849bf5dd9082c02817162aed590f23a4073b/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app/Microsoft.CSharp.dll

        			2023-08-19T08:32:47
Message		Done executing task "Codesign" -- FAILED.			2023-08-19T08:32:47

@rolfbjarne
Copy link
Member

Also looping @rolfbjarne in case he thinks we need anything else.

A binlog for both the failing project, and the working (blank) project would be great.

@Varmod
Copy link
Author

Varmod commented Aug 22, 2023

Hi, I changed the extension from .binlog to .log so github would allow me to upload the file.

binlog of MyApp failing:
MyApp_Debug_AnyCPU_net7.0-ios_Build_2023-08-22T20_06_13.3600170+02_00.log
binlog of BlankApp deploying:
BlankApp_Debug_AnyCPU_net7.0-ios_Build_2023-08-22T19_54_53.2166680+02_00.log

or here's also a zip:
binlogs.zip

@rolfbjarne
Copy link
Member

Those binlogs didn't quite contain the information I was looking for :/

Does the project build correctly from the command line?

https://learn.microsoft.com/en-us/xamarin/ios/get-started/installation/windows/connecting-to-mac/#build-ios-apps-from-the-windows-command-line

If not, could you get a binlog from a command-line build (it will contain more information than when built from inside VS)?

@Varmod
Copy link
Author

Varmod commented Aug 23, 2023

No, it doesn't build from the command line either. It fails with the same error, but this time it's not complaining about the Microsoft.CSharp.dll but one of my embedded videos again.

As for the binlog, I wasn't able to capture it. VS does pick up that there is a solution build running but it never finishes.

@Varmod
Copy link
Author

Varmod commented Aug 23, 2023

I've removed a couple more of my file and now it's failing on System.Security.Cryptography.aotdata.arm64

@rolfbjarne
Copy link
Member

As for the binlog, I wasn't able to capture it.

When you're building from the command line it's much easier: just add "-bl:msbuild.binlog" to the command line, and the binlog will be stored in the current directory.

@Varmod
Copy link
Author

Varmod commented Aug 24, 2023

Ah, perfect. Here's the binlog:

binlog.zip

@rolfbjarne
Copy link
Member

This is all rather puzzling, I don't understand what's going on. codesign shouldn't complain about an mp4 file :/

Would it be possible for you to zip up and attach the app bundle it's trying to sign (from the Mac)?

/Users/jakubH/Library/Caches/Xamarin/mtbs/builds/PosunkujHravo/a5aadbf6ab12cae6ebac45c234ae849bf5dd9082c02817162aed590f23a4073b/bin/Release/net7.0-ios/ios-arm64/PosunkujHravo.app

@Varmod
Copy link
Author

Varmod commented Aug 24, 2023

yeah, sure thing:
https://www.icloud.com/iclouddrive/0d4G6Y07OCLnFGJiCxJgRVEvA#ios-arm64

I'm going to try to port the app into a new template and see when (if) it's going to break.

@PureWeen PureWeen added the s/needs-info Issue needs more info from the author label Aug 24, 2023
@ghost
Copy link

ghost commented Aug 24, 2023

Hi @Varmod. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. 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.

@Varmod
Copy link
Author

Varmod commented Aug 24, 2023

I was able to reproduce the issue. My database file is the source of the problems, once it's added to the project the project won't codesign. I'm getting the same error as first time

Error		Failed to codesign '/Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/9f4da114871512bf3b5dc98fc7a0744bf5ced3f5d72567ce5fba17d8aa5361bd/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app': /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/9f4da114871512bf3b5dc98fc7a0744bf5ced3f5d72567ce5fba17d8aa5361bd/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app: code object is not signed at all
In subcomponent: /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/9f4da114871512bf3b5dc98fc7a0744bf5ced3f5d72567ce5fba17d8aa5361bd/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app/Microsoft.CSharp.dll

Database: Signs.zip

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Aug 24, 2023
@rolfbjarne
Copy link
Member

I was able to reproduce the issue. My database file is the source of the problems, once it's added to the project the project won't codesign. I'm getting the same error as first time

Error		Failed to codesign '/Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/9f4da114871512bf3b5dc98fc7a0744bf5ced3f5d72567ce5fba17d8aa5361bd/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app': /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/9f4da114871512bf3b5dc98fc7a0744bf5ced3f5d72567ce5fba17d8aa5361bd/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app: code object is not signed at all
In subcomponent: /Users/user/Library/Caches/Xamarin/mtbs/builds/MyApp/9f4da114871512bf3b5dc98fc7a0744bf5ced3f5d72567ce5fba17d8aa5361bd/bin/Debug/net7.0-ios/ios-arm64/device-builds/iphone12.1-16.6/MyApp.app/Microsoft.CSharp.dll

Database: Signs.zip

The problem is that there's a subdirectory named "Resources". If you rename this directory to anything else, signing works fine.

@Varmod
Copy link
Author

Varmod commented Aug 25, 2023

That indeed fixes my deployment issues. Thank you

I don't understand then why the default maui template has a Resources folder.
Also I'm sure I've deployed my app several times before even with it being named Resources? There is probably something more to the issue

@rolfbjarne
Copy link
Member

I don't understand then why the default maui template has a Resources folder.
Also I'm sure I've deployed my app several times before even with it being named Resources? There is probably something more to the issue

We have some build logic that will usually put content from the Resources folder from your project in the root directory of the app bundle. For some reason that logic isn't kicking in for your project.

In any case I'm closing this since it seems it's working for you now.

@samhouts samhouts added the s/no-repro Can no longer be reproduced on latest label Aug 28, 2023
@samhouts samhouts added the potential-regression This issue described a possible regression on a currently supported version., verification pending label Sep 5, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 5, 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) area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-attention Issue has more information and needs another look s/no-repro Can no longer be reproduced on latest t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants