Skip to content

Maui - some nugets do not work as path is too long "Could not find a part of the path" #17828

Closed as not planned

Description

@Zack-G-I-T

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

  1. Download Xamarin.Firebase.iOS.CloudMessaging nuget in a new maui app.
  2. 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

  1. added
    t/bug
    on Oct 4, 2023
  2. added
    area-publishing
    on Oct 4, 2023
  3. added
    migration-compatibility
    on Oct 5, 2023
  4. jonathanpeppers commented on Oct 11, 2023

    @jonathanpeppers
    Member
  5. added
    partner/ui-tools
    partner/platform-tools
    and removed
    partner/ui-tools
    on Oct 11, 2023
  6. mauroa commented on Oct 11, 2023

    @mauroa
    Contributor

    Created AzDO bug since it belongs to the Platform Tools team: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1899665

  7. radderz commented on Oct 16, 2023

    @radderz

    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.

  8. jonathanpeppers commented on Oct 16, 2023

    @jonathanpeppers
    Member

    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

    We should file a bug with Windows, if that is the case, this is unrelated to MAUI.

    As to the error above:

    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'.
    

    Do you know what changed? When it worked, was the path just shorter?

  9. radderz commented on Oct 16, 2023

    @radderz

    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.

  10. Zack-G-I-T commented on Oct 17, 2023

    @Zack-G-I-T
    Author

    @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.

  11. mauroa commented on Oct 23, 2023

    @mauroa
    Contributor

    @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

  12. radderz commented on Oct 23, 2023

    @radderz

    @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.

    image

    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.

  13. 46 remaining items

  14. radderz commented on May 24, 2024

    @radderz

    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.

  15. improwise commented on Jun 4, 2024

    @improwise

    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...

  16. khalil2099 commented on Jun 4, 2024

    @khalil2099

    Is there any news on this? Any confirmed way of working around yet?

    have you even tried the proposed solution ?

  17. khalil2099 commented on Jun 4, 2024

    @khalil2099

    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...

    because there are work around for this problem already.

  18. improwise commented on Jun 4, 2024

    @improwise

    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...

    because there are work around for this problem already.

    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...

  19. khalil2099 commented on Jun 4, 2024

    @khalil2099

    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...

    because there are work around for this problem already.

    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...

    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.

    image

    Post your error output here.

  20. improwise commented on Jun 4, 2024

    @improwise

    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...

    because there are work around for this problem already.

    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...

    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.

    image

    Post your error output here.

    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.

  21. improwise commented on Jun 4, 2024

    @improwise

    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

    <PropertyGroup>
    	<BaseOutputPath>..\..\..\..\..\temp\</BaseOutputPath>
    </PropertyGroup>
    

    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.

  22. ia3n commented on Jun 4, 2024

    @ia3n

    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.

  23. AlleSchonWeg commented on Jun 5, 2024

    @AlleSchonWeg
    Contributor

    It is more a visual studio issue: https://developercommunity.visualstudio.com/t/Allow-building-running-and-debugging-a/351628
    Upvote it. Perhaps it helps.

  24. improwise commented on Jun 11, 2024

    @improwise

    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...

    because there are work around for this problem already.

    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...

    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.

    image

    Post your error output here.

    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.

    <PropertyGroup>
    	<BaseOutputPath>..\..\..\..\..\temp\</BaseOutputPath>
    </PropertyGroup>
    

    Edit:

    Wierdly enough, now it seems to work with absolute paths as well, something that did not work before, like

    <PropertyGroup>
    	<BaseOutputPath>M:\temp\</BaseOutputPath>
    </PropertyGroup>
    
  25. NeilPSingular commented on Sep 10, 2024

    @NeilPSingular

    This worked for me:

    nuget install <Package-Name> in the cmd of the project directory

  26. jfversluis commented on Sep 21, 2024

    @jfversluis
    Member

    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.

  27. locked and limited conversation to collaborators on Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-publishingblockedmigration-compatibilitypartner/platform-toolsplatform/iost/bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions