Kebechet / Maui.RevenueCat.InAppBilling

MIT License
13 stars 6 forks source link

IOS - Publishing App fails when package included #7

Closed CameronVetter closed 1 year ago

CameronVetter commented 1 year ago

The app deploys fine in debug or release to devices from VS2022, but when publishing the app for IOS the IDE shows that the packaging has completed but the progress bar keeps going forever (just tried it over night). The packaging works fine for Android. When I look at the archives folder I find that there is an archive there with most of the files there. In VS 2022 after restarting when I "view archives" no archives appear (I believe VS is throwing an exception). Deleting the folder for the new archive and restarting VS2022 allows it to return to normal.

The only clue is looking in the Xamarin logs where I see this:

Xamarin.Messaging.Ssh.MessagingService Information: 0 : Agent Build 16.4.7089 is running: 08/08/2023 03:54:18Z
    DateTime=2023-08-08T03:54:18.2976305Z: 08/08/2023 03:54:18Z
Xamarin.VisualStudio.Progress.ProgressReportService Information: 0 : App archive 'Board Game Copilot' completed successfully.: 08/08/2023 03:55:30Z
    DateTime=2023-08-08T03:55:30.7816782Z: 08/08/2023 03:55:30Z
Xamarin.VisualStudio.Progress.ProgressReportService Information: 0 : !App archive 'Board Game Copilot' completed successfully.: 08/08/2023 03:55:30Z
    DateTime=2023-08-08T03:55:30.7816782Z: 08/08/2023 03:55:30Z
Xamarin.VisualStudio.Publishing.Presentation.ViewModels.ArchiveListViewModel Error: 0 : System.IO.FileNotFoundException: Could not find file 'C:\Users\camer\AppData\Local\Xamarin\iOS\Archives\2023-08-07\Board Game Copilot 8-07-23 10.55 PM.xcarchive\Products\Applications\Board Game Copilot.app\Frameworks\RevenueCat.framework\Modules\RevenueCat.swiftmodule\x86_64-apple-ios-simulator.private.swiftinterface'.
File name: 'C:\Users\camer\AppData\Local\Xamarin\iOS\Archives\2023-08-07\Board Game Copilot 8-07-23 10.55 PM.xcarchive\Products\Applications\Board Game Copilot.app\Frameworks\RevenueCat.framework\Modules\RevenueCat.swiftmodule\x86_64-apple-ios-simulator.private.swiftinterface'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileInfo.get_Length()
   at Xamarin.VisualStudio.IOS.Publishing.IOSProjectArchive.get_Size() in D:\a\_work\1\s\src\Core\VisualStudio.IOS\ProjectSystem\Publishing\IOSProjectArchive.cs:line 233
   at Xamarin.VisualStudio.Publishing.Presentation.ViewModels.BuildViewModel.SetModel(IProjectArchive model) in D:\a\_work\1\s\src\Core\VisualStudio.Publishing\Presentation\ViewModels\BuildViewModel.cs:line 298
   at Xamarin.VisualStudio.Publishing.Presentation.ViewModels.BuildViewModel..ctor(ArchiveViewModel archiveViewModel, IProjectArchive model, IArchiveManager archiveManager, JoinableTaskFactory asyncManager, IEventStream eventStream, IProgressReportService progressReportService) in D:\a\_work\1\s\src\Core\VisualStudio.Publishing\Presentation\ViewModels\BuildViewModel.cs:line 123
   at Xamarin.VisualStudio.Publishing.Presentation.ViewModels.ArchiveListViewModel.<OnNewBuildCompletedAsync>d__60.MoveNext() in D:\a\_work\1\s\src\Core\VisualStudio.Publishing\Presentation\ViewModels\ArchiveListViewModel.cs:line 0
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.VisualStudio.Publishing.Presentation.ViewModels.ArchiveListViewModel.<>c__DisplayClass59_3.<<SubscribeToEvents>b__10>d.MoveNext() in D:\a\_work\1\s\src\Core\VisualStudio.Publishing\Presentation\ViewModels\ArchiveListViewModel.cs:line 315: 08/08/2023 03:55:30Z
    DateTime=2023-08-08T03:55:30.8121999Z: 08/08/2023 03:55:30Z
CameronVetter commented 1 year ago

Getting Publish to work again after removing the package was pretty hard. I had to shut down visual studio, delete all obj and bin folders by hand, then do a clean and rebuild before publish would work again. After doing this I can verify that removing this package allowed the app to publish again.

CameronVetter commented 1 year ago

I was able to get back to this problem today. The issue is that the file path is getting too long. After a bunch of research I figured out that the maximum length for the win32 API call (yes really) called during the publish process is 260 characters, in the chunk I shared that was up to 263 characters. I moved the Archives folder (in VS2022 options) to a shorter folder length and it worked just fine.

I'm not sure I have a great answer on what could change in this code base to fix this... But at least this is an answer for the next person, so they don't waste as many hours as I did.

Kebechet commented 1 year ago

I experienced this problem as well locally while working with Admob library. Workaround for this is to setup registry for windows: https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/The-Windows-10-default-path-length-limitation-MAX-PATH-is-256-characters.html

I reported similar issue(with mentioned Admob library) here: https://github.com/dotnet/maui/issues/15042

The best thing to have is to automate whole deployment process through github/azure pipelines. I had a lot of problems with local artifacts as well, but pipelines always start on fresh machine so now I dont deploy from my PC anything.

CameronVetter commented 1 year ago

I did start setting up pipelines, but ran into so many MAUI problems that I gave up, I'll have to give it another try. I tried to track through that issue, but couldn't follow all the related issues, did they actually fix it in .net8?

Kebechet commented 1 year ago

MAUI problems ? I didnt experience anything other than problems regarding iOS certificates (it took me a while to set it up properly).

Regarding that issue, I have no idea, it went through so many other issues I also lost track of that.

Kebechet commented 1 year ago

@CameronVetter can I close this issue ? Because it is caused by MAUI itself so we cant do anything with this