Repository navigation
Description
Description
Using the Xamarin.Firebase.iOS.CloudMessaging nuget in .NET Maui.
Android works fine, but in iOS we get this error. I believe it is because the file path is too long - however I have set the system settings to enable long paths and still get this exception. I am using Windows 10 if that is relevant.
**An error occurred while trying to deploy the app 'SamplePush.app'. Details: Could not find a part of the path
'C:\Users\username\AppData\Local\MyTempFiles\Xamarin\HotRestart\Signing\SamplePush.app\out\Payload\SamplePush.app\SamplePush.content\Firebase.CloudMessaging.resources\FirebaseMessaging.xcframework\ios-arm64\FirebaseMessaging.framework\Headers\FirebaseMessaging-umbrella.h'.**
I changed my temp file location to be shorter C:\tmp but still get the following:
**An error occurred while trying to deploy the app 'SamplePush.app'. Details: Could not find a part of the path
'C:\Tmp\Xamarin\HotRestart\Signing\SamplePush.app\out\Payload\SamplePush.app\SamplePush.content\Firebase.Core.resources\GoogleUtilitiesComponents.xcframework\ios-arm64_x86_64-simulator\GoogleUtilitiesComponents.framework\Headers\GoogleUtilitiesComponents-umbrella.h'**
Steps to Reproduce
- Download Xamarin.Firebase.iOS.CloudMessaging nuget in a new maui app.
- Try and debug in ios and see exception.
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 Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
An error occurred while trying to deploy the app 'SamplePush.app'. Details: Could not find a part of the path
'C:\Users\username\AppData\Local\MyTempFiles\Xamarin\HotRestart\Signing\SamplePush.app\out\Payload\SamplePush.app\SamplePush.content\Firebase.CloudMessaging.resources\FirebaseMessaging.xcframework\ios-arm64\FirebaseMessaging.framework\Headers\FirebaseMessaging-umbrella.h'.
Activity
jonathanpeppers commentedon Oct 11, 2023
Does enabling long paths help here at all?
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later
/cc @emaf @mauroa
mauroa commentedon Oct 11, 2023
Created AzDO bug since it belongs to the Platform Tools team: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1899665
radderz commentedon Oct 16, 2023
Note, long file paths doesn't work in windows 11 at all, both the registry setting and group policy option doesn't work with long paths anymore so this long paths issue is a pretty major regression. Not being able to use Firebase for instance for push notifications is crippling our ability to test our apps.
jonathanpeppers commentedon Oct 16, 2023
We should file a bug with Windows, if that is the case, this is unrelated to MAUI.
As to the error above:
Do you know what changed? When it worked, was the path just shorter?
radderz commentedon Oct 16, 2023
I imagine the path was shorter, any filename over 260 will fail in windows 11, when it was possible to get it working in window 10. I am not sure when this started failing but it's pretty painful after updating our devs all with new laptops running windows 11.
I put the note in here incase that was the issue and it looks like this filename is 271 in length so the long file names setting would need to be enabled to work for this to function. The issue comes from the nuget package download/unzip, which fails due to the long file names. Then the copying to the obj folder can have the same effect if that path ends up too long too.
I am unsure if @Zack-G-I-T is using windows 11 but if he is then I'd say that is the problem he is experiencing.
Edit: @Zack-G-I-T is using Windows 10. You should look up enabling long filenames in registry to allow file paths > 260 in length. After doing that you need to delete the package from your nuget cache as it is already there in a bad state and visual studio will not restore it for you.
Zack-G-I-T commentedon Oct 17, 2023
@radderz Hi, I am on Windows 10 and I tried enabling long file names in regedit and in group policy and i deleted my whole nuget cache but it didnt work.
I ended up having to delete the "_CopyLocalBindingResources" tag from my Xamarin.Shared.Sdk.targets" for it to work.
mauroa commentedon Oct 23, 2023
@radderz @Zack-G-I-T how are you installing the FireBase NuGet package? If it's by adding a PackageReference or using the Package Manager Console, I guess you are getting an error on installation or restore time, aren't you? I'm just trying to understand if that's the first error you are facing or if it's directly when building the MAUI app for iOS. That would help us to determine the best route for the issue. Thanks
radderz commentedon Oct 23, 2023
@mauroa it is when trying to build, it tries to copy the contents of the nuget to the obj folder for build, but the file doesn't exist as at nuget restore time since the initial zip extraction fails. It basically gives a cannot copy file error and the overall path is way too long.
I tried to change the nuget cache folder to have as short a path as possible but it still fails since it copies it to the obj folder of the project which has a longer path.
46 remaining items
radderz commentedon May 24, 2024
This only helps if the package files have short enough folder locations that this brings it under the threshold, but this isn't enough for some packages that even C:\N\ as the nuget folder which is the shortest possible still breaches the threshold.
improwise commentedon Jun 4, 2024
Can't help but to wonder if it would not be easier for everyone if Microsoft just killed of MAUI since they obviously don't care anymore...this problem has been around for years and yet...
khalil2099 commentedon Jun 4, 2024
have you even tried the proposed solution ?
khalil2099 commentedon Jun 4, 2024
because there are work around for this problem already.
improwise commentedon Jun 4, 2024
Please tell me one that works as I have tried all that I have found and none is working and I am obviously not the only one with problems...
khalil2099 commentedon Jun 4, 2024
Yes im also having this problem before this, but i managed to solved it. I even complain about it on this thread on Feb 2024.
Have you tried this ? But before you try this, u need to enable Long Path Names and also delete your Bin and Obj folder inside your project folder. I have tried this with two different machine and no problems.
Post your error output here.
improwise commentedon Jun 4, 2024
Thanks, will give that a try as well. But when not even latest VS can do MAUI in 2024, I just can't help but to think that we need to consider our options here. But that is of course another discussion not related to this issue.
improwise commentedon Jun 4, 2024
We were actually able to find a solution (ie workaround) that actually seem to work in VS as well. It is not pretty but here goes
We tried with different variants of something like "C:\temp" instead but never got it to work with our other build scripts. There are of course nicer ways to solve this still using relative paths but right now we were just looking for a quick and dirty way of making it work...
Of course you may need to adjust the number of ".." based on your folder structure etc. The idea here is to get a relative path (to make MSBuild happy) but still get a path short enough to make Windows / VS happy as well.
ia3n commentedon Jun 4, 2024
Coming back a month later to confirm that YES many of these workarounds will solve the issue - keep trying! For us it was the earlier suggestion to open windows powershell and enter:
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
Also a reminder that this was an issue in Xamarin.iOS long before it was a MAUI issue. MAUI has introduced a number of new headaches for us, sure, but this is an old one. The bigger problem here is that in Xamarin.iOS the simple workaround was to use older packages and .net requires the recent ones so it's been harder to fix.
After my initial frustrated rant (which I stand by) I do want to note that we've been pleasantly surprised to find that once you get it up and running, MAUI works... really well. We've successfully rolled out several updates on Android and iOS over the past month, have integrated all firebase nugets successfully (including FCM) since the .net team updated them recently and are considering releasing to the Windows store for the first time ever. Billing is simple with James Montemagno's excellent cross-platform nuget, and Admob is now working on all apps. We're also seeing fewer ANRs than when our apps were written in Xamarin, and maintenance is so much easier than running two native builds. Expect to do some workaround-hunting and a lot of 'Clean Solution + delete Obj & Bin folders, but if you're deep in the .net and just looking to transfer your code across from Xamarin, I would say it's worth it and don't give up.
AlleSchonWeg commentedon Jun 5, 2024
It is more a visual studio issue: https://developercommunity.visualstudio.com/t/Allow-building-running-and-debugging-a/351628
Upvote it. Perhaps it helps.
improwise commentedon Jun 11, 2024
This only seem to work for a while but not once you need to build etc again, at least not for us. The solution (workaround) I posted above works over time though once you have put it into the project file (at least it does for us, YMMV of course). Best would be if MS just fixed this in VS.
Edit:
Wierdly enough, now it seems to work with absolute paths as well, something that did not work before, like
NeilPSingular commentedon Sep 10, 2024
This worked for me:
nuget install
<Package-Name>in the cmd of the project directoryjfversluis commentedon Sep 21, 2024
As pointed out a couple of times, unfortunately this is not a .NET MAUI problem but wider spread and older.
I think there is a couple of variations of this either in Windows or Visual Studio, this seems to be a VS Feedback ticket with a good number of comments and votes so please upvote that one and/or add your scenario there and hopefully it will be fixed soon!
Since this is not actionable on our side and this has now accumulated a good number of workarounds to help people move forward, closing this for now here.