OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
104 stars 50 forks source link

Unable to upgrade 4.1.0 however 4.0.0 works fine #312

Closed Dipannita20 closed 1 year ago

Dipannita20 commented 2 years ago

Description:

(your description here)

Environment

Visual Studio 2019 Professional windows

Steps to Reproduce Issue:

  1. Right click Manage Nuget Packages for Solution
  2. Browse OneSignalSDK.Xamarin select any project share, android, iOS and 4.1.0
  3. Click install

Package not installing getting below error, attached exception

Anything else:

onesignal_4.1.0_upgrade_exception.txt n here)

ChrisMonson commented 2 years ago

Just adding a little bit of additional troubleshooting information on this one as I ran into this a couple days ago. I believe this is happening because the directory structure after extracting the files from the nuget package winds up with file paths that exceed 260 characters which is the default maximum in Windows. This causes the files to not actually get created thus resulting in the "Could not find a part of the path" error you are getting. If you look in the location listed, the folder will contain files with shorter filenames but will be missing the file referenced and probably several others.

I was able to work around this by moving my project closer to the drive's root directory, deleting the OneSignal package from the packages folder, and restoring the package. Since the paths will be shorter at this point, it all worked properly.

This only affects Windows, as the max path length on Mac is much longer.

Dipannita20 commented 2 years ago

I have moved my project to closer to drive root directory Deleted OneSignal Package from packages folder But as I am trying to install OneSignalSDK.Xamarin, it is getting installed in C:\Users\dipannitad.nuget\packages. I have verified as you have mentioned other files are present only OneSignalNotificationServiceExtensionHandler.h file is missing.

"deleting the OneSignal package from the packages folder, and restoring the package" Could you please provide me exact steps, it will be really helpful

Thank you

ChrisMonson commented 2 years ago

Ahh, I forgot about that step. I wound up having to go in and remove the OneSignalSDK.Xamarin package from the global NuGet package folder on my computer as well. The file path length issue is unfortunately an issue there as well. I just went to the folder you listed above, found the OneSignalSDK.Xamarin folder and removed it. There is probably a better way to go about that, but that worked for me.

As for steps, I closed Visual Studio, removed the package, and then restarted Visual Studio. Visual Studio automatically restored the package to the project's packages directory with the shorter directory path and it worked properly after that.

This isn't really a good long term solution to this problem, and I'm sure there is probably a much better way to do this through the NuGet CLI, but these steps did work for me.

developer9969 commented 2 years ago

I Have the same issue - and I could not upgrade to 4.10 to see if some other issues that exists on 4.0.0 were fixed.

What changed between 4.0.0 and 4.10 @jkasten2

thanks

Dipannita20 commented 2 years ago

This is how I have solved. Change default nuget package installation path: Go to C:\Users\xxxxx\AppData\Roaming\NuGet - open nuget.config -> then add below inside <configuration>, value here can be anything set to close to drive root

<config>
    <add key="globalPackagesFolder" value="D:\nuget" />
   </config>

OR you can create nuget.config to your project solution folder, where .sln file is present and add

<configuration>
<config>
    <add key="globalPackagesFolder" value="E:\nuget" />
   </config>
</configuration>

Then do nuget restore, it basically install all the nuget packges to new location. now install OneSignalSDK.Xamarin as the path become short, it will get install.

Thanks @ChrisMonson for helping me out

developer9969 commented 2 years ago

@Dipannita20 thank you for your time and reply. I have already a solution nuget config as follows:

`

<?xml version="1.0" encoding="utf-8"?>

` I have added 1. ` ` 2. Right clicked solution and did restore packages - tried command line too 3. Nothing changed as the path did not take effect. Missing the obvious? thanks
developer9969 commented 2 years ago

@Dipannita20 yep managed to make it work as you suggested - now 4.1.0 installs however I still get

Severity Code Description Project File Line Suppression State Error Unable to copy file " C:\Nuget\onesignalsdk.xamarin\4.1.0\build\Xamarin.iOS....\content\OneSignalSDK.Xamarin.iOS.resources\OneSignalCore.xcframework\ios-arm64_x86_64-maccatalyst\OneSignalCore.framework\Versions\A\Headers\OSPrivacyConsentController.h" to "PathToMyApp.iOS\bin\iPhoneSimulator\Debug\/OneSignalSDK.Xamarin.iOS.resources/OneSignalCore.xcframework\ios-arm64_x86_64-maccatalyst\OneSignalCore.framework\Versions\A\Headers\OSPrivacyConsentController.h". Could not find a part of the path 'c:\PathToMyApp.iOS\bin\iPhoneSimulator\Debug\/OneSignalSDK.Xamarin.iOS.resources/OneSignalCore.xcframework\ios-arm64_x86_64-maccatalyst\OneSignalCore.framework\Versions\A\Headers\OSPrivacyConsentController.h'.
MyApp.iOS

and I dont get that at all with V3 or V4.0..

Any ideas anyone