Bug 61113 - Unable to update NuGet packages in Android projects in VS 15.5
Summary: Unable to update NuGet packages in Android projects in VS 15.5
Status: CONFIRMED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: 4.8.0 (15.5)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-12-18 07:18 UTC by Jens-Christian
Modified: 2018-05-07 19:25 UTC (History)
21 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 61113 on Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.
Related Links:
Status:
CONFIRMED

Description Jens-Christian 2017-12-18 07:18:28 UTC
After updating to VS 15.5 I'm unable to update NuGet packages in Android projects, both libraries and applications.

I have gotten the error while updating Xamarin.Forms and Xamarin.Android.Support.* packages.

The error message is "This collection is read-only."

Full log from Package Manager
Attempting to gather dependency information for multiple packages with respect to project 'Applications\LexTalk.Android', targeting 'MonoAndroid,Version=v7.1'
Gathering dependency information took 18,9 sec
Attempting to resolve dependencies for multiple packages.
Resolving dependency information took 0 ms
Resolving actions install multiple packages
Retrieving package 'Xamarin.Forms 2.5.0.121934' from 'nuget.org'.
Removed package 'Xamarin.Forms 2.4.0.38779' from 'packages.config'
Successfully uninstalled 'Xamarin.Forms 2.4.0.38779' from LexTalk.Android
Adding package 'Xamarin.Forms.2.5.0.121934' to folder 'U:\Repos\LexTalk\packages'
Added package 'Xamarin.Forms.2.5.0.121934' to folder 'U:\Repos\LexTalk\packages'
Install failed. Rolling back...
Package 'Xamarin.Forms 2.5.0.121934' does not exist in project 'LexTalk.Android'
Package 'Xamarin.Forms 2.4.0.38779' already exists in folder 'U:\Repos\LexTalk\packages'
Added package 'Xamarin.Forms 2.4.0.38779' to 'packages.config'
Removing package 'Xamarin.Forms 2.5.0.121934' from folder 'U:\Repos\LexTalk\packages'
Removed package 'Xamarin.Forms 2.5.0.121934' from folder 'U:\Repos\LexTalk\packages'
Executing nuget actions took 38,21 sec
This collection is read-only.
Time Elapsed: 00:00:57.4296499
========== Finished ==========


And I'm not the only getting this error:
https://forums.xamarin.com/discussion/111931/cannot-update-googleplayservices-60-1142-0
Comment 1 George Ceaser 2018-01-07 21:15:55 UTC
I am getting the same error.  I somehow managed to get everything to update except the four Xamarin.GooglePlayServices (Base, Basement, Maps, Tasks).  When I attempted to update them I go the error message 
Package 'Xamarin.GooglePlayServices.Basement.60.1142.0' already exists in folder
then in started rolling back and showed the error "This collection is read only".  I tried to manually install just the Basement - which worked - but then the other three packages (Base, Maps, Tokens) were not longer in my nugget package list for the project.  Their reference is still in the project thought
Comment 2 George Ceaser 2018-01-07 21:19:57 UTC
I attempted to install the compatible (60.1142.0) version of the .base nugget package and it failed as follows and ended with the "This collection is read only" error.
Comment 3 Jens-Christian 2018-01-11 08:16:51 UTC
Problem still exists in VS 15.5.3 and 15.6.0 Preview 2.0

Time to fix this ???
Comment 4 ted 2018-01-12 09:27:19 UTC
Hi 
I got the same error too, when upgrading an android project with the latest xamarin.Forms(2.5.0.122203) I managed to clear the "Collection is read only error" by removing the previous version of xamarin forms and reinstalling it.

Hope it helps anybody
Comment 5 reynald.monares.haiyan 2018-01-22 05:35:10 UTC
hi.
i am now getting the same issue.

I tried to uninstall the previous xamarin.forms version in my android project and install the latest xamarin.forms version 2.5.0.122203 but the issue is still there. Any fixes yet?
Comment 6 Jens-Christian 2018-01-22 07:16:37 UTC
This issue is also tracked at  https://developercommunity.visualstudio.com/content/problem/169526/nuget-get-error-this-collection-is-read-only-while.html, and i looks like it have been moved to https://github.com/NuGet/Home/issues/6468.

So the error is reported at least three places, so hopefully i will be fixed soon.
Comment 7 Josh Russo 2018-01-24 19:15:46 UTC
I'm also experiencing this trying to update Xamarin.Android.Support.xxx packages, Xamarin.Firebase.xxx packages, and Xamarin.GooglePlayServices.xxx packages, 22 packages in all.

My Visual Studio version is 15.5.4
Comment 8 Josh Russo 2018-01-24 22:26:53 UTC
I was able to resolve my issue. Some of the files in the packages folder were set to read-only. I cleared the read-only flag from all files in the packages folder and then the packages updated successfully
Comment 9 Jens-Christian 2018-01-29 08:32:31 UTC
Error is still in VS 15.5.5, and it's starting to become a big problem, I'm unable to do anything usefull regarding updating Xamarin.Forms on Android.
Comment 10 Nicolai Schönberg 2018-02-28 10:52:00 UTC
I had this issue recently when I updated all my projects from  using XF 2.4 to XF 2.5. I had the same issue for my android project. I deleted obj\ and bin\ folders for my solution and updated nuget packages again only for my android project (Was using solution wide upgrade before). The problem is solved for me
Comment 11 Philippe Leybaert 2018-03-08 20:03:46 UTC
Problem still exists in Visual Studio 2017 15.6. Updating the Xamarin Forms Nuget package or any of the Android Support library packages fails with the error "This collection is read-only".

Workarounds:

1. Update every nuget package one by one and select "Ignore Dependencies". This takes forever and sometimes needs multiple tries 

2. Open the project in Visual Studio for Mac (15.6) and update the packages. Works like a charm so it's a Windows-only issue.
Comment 12 mr.pearce 2018-03-09 12:44:20 UTC
Just tested it with VS 2017 15.6.1 and the Xamarin.Android.Support... Packages
Still shows "This collection is read-only"
Comment 13 Peter 2018-03-20 16:57:19 UTC
The error occurs if you install multiple updates. You can see in the output window "Installation failed. Roll back ..."
If you restart VS you can install the next (the failed) package, then the next failed ... So if you try again and again and restart VS every time, sometimes all package will be updated. So I think it's an error in updating the package list.
Comment 14 batmaci 2018-03-22 12:02:45 UTC
does this bug not belong to xamarin android? dont we need to move it to Github issues?
Comment 15 Jens-Christian 2018-03-22 13:22:43 UTC
This bug is also filed in the NuGet repository on GitHub, at https://github.com/NuGet/Home/issues/6468, and it's fixed there.

So we just need to wait to be included in VS ...
Comment 16 Mike Miller 2018-04-03 12:11:47 UTC
I'm having the same issue.  I'm on 15.6.4
Comment 17 Mike Miller 2018-04-03 12:30:34 UTC
I was also able to confirm that it does work on Mac as stated in Comment 11.
Comment 18 Philippe Leybaert 2018-04-03 23:08:01 UTC
Any update on this? This is a blocker issue and Microsoft is blaming it on Xamarin.

It renders Xamarin almost unusable. Without jumping through numerous hoops, it's impossible to update Xamarin Forms to the latest version using Visual Studio
Comment 19 mr.pearce 2018-04-04 08:52:56 UTC
I kinda fixed it by updating my pcl to netstandard and changing all projects to the new PackageReference in project.csproj file format.

Remove all nuget references on all projects(will probably need to force remove them)
In VS->Tools->Options->Nuget Package Manager->General "Allow format seletion on first package install" should be turned on.

When installing the packages again, VS should ask if you want to use PackageReference or Package.config. 
Chose PackageReference

Add back your Nugets (this should be much quicker now by the way)
Comment 20 Jorge Castro 2018-04-04 20:21:12 UTC
So yes, still an issue after so long, had to test reinstalling nuget packages for android because app center cannot find dlls that should be there, possibly an android reference somewhere, but since nuget is unusable for reinstalling still not sure what we should do, ignoring this reveals how much they care :)

Executing nuget actions took 14.51 min
update-package : This collection is read-only.
At line:1 char:1
+ update-package -reinstall
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Update-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
Comment 21 Sandip Ahluwalia 2018-04-10 08:55:48 UTC
I have the same issue too. I am trying to update my Xamarin.Forms package from 2.5.0.122203 to 2.5.1.444934 and I am using Visual Studio v15.5.6 so that I can use the latest Xamarin.Forms.Maps package. The update works for the shared .NET standard, iOS and UWP projects, but always fails on the Android one with this "This collection is read-only." message. I have tried some of the suggestions above, but no success so far. Is there a definitive list of workaround steps to follow to get this working whilst we wait for the fix?
Comment 22 Mike Miller 2018-04-10 15:43:43 UTC
If you have a Mac, doing the package update there seems to work.
Comment 24 Clay 2018-04-12 15:47:00 UTC
I had the same problem.  I did the following:

Restarted VS

I had to install in a specific order:

* Xamarin.Build.Download (latest version)
* Xamarin.GooglePlayServices.Basement (lastest version)
* Xamarin.GooglePlayServices.Tasks (latest version)
* Xamarin.GooglePlayServices.Base (latest version)
* Xamarin.GooglePlayServices.Maps (I was trying to use Xamarin.Forms.Maps, latest version)

Then install

* Xamarin.Forms.Maps (same version as your xamarin forms)
Comment 25 ted 2018-04-14 06:24:23 UTC
Hi
Can somebody from the Xamarin Team sort this issue out or tell us what workaround to use.

Its clearly a problem when trying to install Xamarin.Forms.Maps on a project.

We are stuck and I tried all workarounds with no success.
Comment 26 Philippe Leybaert 2018-05-07 19:25:24 UTC
Today VS2017 version 15.7 was released and this issue is still not fixed.

"This collection is read-only" when trying to update the Xamarin Forms nuget package for an Android project.