Reputation: 83
I am developing a .NET MAUI application for iOS that requires push notifications. As far as I can tell, Firebase Cloud Messaging is the standard way to accomplish this. All of the NuGet packages I have tried to install for Cloud Messaging have given me the following error message:
Could not find a part of the path C:\Users\user.nuget\packages\xamarin.firebase.ios.installations\8.10.0.3\lib\net6.0-ios15.4\Firebase.Installations.resources\FirebaseInstallations.xcframework\ios-arm64_x86_64-simulator\FirebaseInstallations.framework\Headers\FirebaseInstallations-umbrella.h'.
As far as I can tell, this is the result of a file path longer than NuGet's 260 character limit. How can I circumvent this limitation? Has anyone successfully implemented a push notification solution in MAUI on iOS?
I have tried increasing the maximum path length as described here. No change. As far as I can tell, Visual Studio uses its own version of NuGet that ignores this.
I have tried using dotnet add package
in the project directory using PowerShell. This appears to install the package, but Visual studio does not appear to recognize that the package is installed when I attempt to build.
Upvotes: 1
Views: 3026
Reputation: 446
As was already mentioned, problem is happening because of exceeding MAX_PATH (260 characters size) of file which is tried to be found. But if mentioned approach do not work try this:
Close all visual studio instances.
Run PowerShell as Administrator and execute this command
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabl ed" -Value 1 -PropertyType DWORD -Force
Create a new folder with name "Nugets" in drive C ( C:\Nugets )
Again run PowerShell as Administrator and execute following command:
[Environment]::SetEnvironmentVariable("NUGET_PACKAGES", "C:\Nugets" ,"Machine")
Delete obj and bin folder of your project
Run Visual Studio and Rebuild Project
7.0 DID not worked yet ?
7.1 Close Visual Studio
7.2 Open CMD/PowerShell and navigate to the folder of your project e.g.:
cd "C:\Users\Admin\source\repos\MySolution\MyProject"
and than run command dotnet restore
7.3 Open Visual Studio again and build
Upvotes: 1
Reputation: 83
This issue is caused by the NuGet long path issue. It can be resolved by adding a Nuget.config file to the solution root with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<clear />
<add key="globalPackagesFolder" value="C:\Nuget" />
</config>
</configuration>
Upvotes: 2