Bug 36913 - Updating package with Nuget removed references
Summary: Updating package with Nuget removed references
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: NuGet ()
Version: Trunk
Hardware: PC Mac OS
: High normal
Target Milestone: (C7)
Assignee: Matt Ward
Depends on:
Reported: 2015-12-11 19:34 UTC by Mikayla Hutchinson [MSFT]
Modified: 2016-05-12 18:52 UTC (History)
1 user (show)

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mikayla Hutchinson [MSFT] 2015-12-11 19:34:10 UTC
I created a new Forms+PCL project, update the Forms package, and the NuGet addin removed the references from the project file. Yet they were still visible in the solution tree:

Comment 1 Mikayla Hutchinson [MSFT] 2015-12-11 20:15:57 UTC
Was able to reproduce this.
Comment 2 Mikayla Hutchinson [MSFT] 2015-12-11 20:16:30 UTC
Xamarin Studio
Version 6.0
Installation UUID: d6961bae-802e-488c-8432-859a337938b1
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

Not Installed

Apple Developer Tools
Xcode 7.2 (9548)
Build 7C68

Version: (Business Edition)
Hash: 9799809
Branch: master
Build date: 2015-11-23 06:19:58-0500

Version: (Business Edition)
Android SDK: /opt/android/sdk
	Supported Android versions:
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 25 rc1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

Xamarin Android Player
Version: 0.5.6
Location: /Applications/Xamarin Android Player.app

Version: (Business Edition)

Build Information
Xamarin addins: f436fc6bd6769fa73a8c1bb31594c69637420ae6

Operating System
Mac OS X 10.11.2
Darwin saturn.local 15.2.0 Darwin Kernel Version 15.2.0
    Fri Nov 13 19:56:56 PST 2015
    root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64

Enabled user installed addins
Addin Maker 1.2.1
Comment 3 Mikayla Hutchinson [MSFT] 2015-12-11 20:18:31 UTC
If I remove and re-add the package, it doesn't add the references/imports either.

If I restart XS then re-add the package, it works.
Comment 4 Mikayla Hutchinson [MSFT] 2015-12-11 20:19:51 UTC
Actually, just reloading the solution is enough.
Comment 5 Mikayla Hutchinson [MSFT] 2015-12-11 20:20:55 UTC
Also, this only happened with the PCL project, not the app project.
Comment 6 Matt Ward 2015-12-14 10:28:24 UTC
This seems to be a problem in the project model. I can reproduce it by doing the following:

1) Create a PCL project.
2) Add a reference using the Edit References to a .dll on disk, such as Newtonsoft.Json.dll.
3) Remove the reference added.
4) Add a reference using the Edit References to a .dll on disk, such as Newtonsoft.Json.dll.

The .csproj no longer has any references after step 4).

The problem seems to be that since the PCL project has no references of its own. When you remove any added assembly references, step 3) above, so none are left in the project then the corresponding item group in the project is removed but is kept around in a bestItemGroup dictionary in the MSBuildProject, so the references can be grouped together. When you then add a reference again, step 4, it adds it back to this references ItemGroup which is in the bestItemGroup dictionary. However this ItemGroup is no longer part of the MSBuildProject so the references are never saved to disk.

I will look at creating a unit test for this problem. Then look at making sure removed item groups are also removed from the bestItemGroup.
Comment 7 xamarin-release-manager 2015-12-14 12:07:12 UTC
Fixed in version (master)

Author: Matt Ward
Commit: ee36637bfdc894f89b33dc32ebdbb01c4480b8b3 (mono/monodevelop)
Comment 8 Akhilesh kumar 2016-05-11 17:35:09 UTC
To verify this issue, I have to reproduce this issue with XS  6.0 (build 9), but I am unable to reproduce this issue. I have used steps mentioned in Comment 6.

After creating Forms PCL project, on adding .dll present on disk via Edit References, .csproj file get updated every time adding and removing then re-adding .dll present on disk. I am sharing a screencast for the same: http://www.screencast.com/t/dTbV4BSc

@Matt, could you please let me know if I am using wrong steps.

Environment info:
=== Xamarin Studio Community ===

Version 6.0 (build 5149)
Installation UUID: b62b65c1-43c6-4926-bdbe-9dc0be5d059f
	Mono 4.4.0 (mono-4.4.0-branch/63a214c) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404000154

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.3 (10183.3)
Build 7D175

=== Xamarin.Mac ===

Version: (Xamarin Studio Community)

=== Xamarin.iOS ===

Version: (Xamarin Studio Community)
Hash: 732e338
Branch: cycle7
Build date: 2016-05-10 16:54:04-0400

=== Xamarin.Android ===

Version: (Xamarin Studio Community)
Android SDK: /Users/360_macmini/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 25.1.3
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.3

Java SDK: /usr
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

Android Designer EPL code available here:

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 600005149
Git revision: bba52b8c08c7203d74954d4fbe1e7c853e24caa3
Build date: 2016-05-10 12:32:30-04
Xamarin addins: 078ae1fc0e27241049abc5118f382b86c016a9d1
Build lane: monodevelop-lion-cycle7

=== Operating System ===

Mac OS X 10.11.4
Darwin 360-MACMINIs-Mac-mini-3.local 15.4.0 Darwin Kernel Version 15.4.0
    Fri Feb 26 22:08:05 PST 2016
    root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64
Comment 9 Matt Ward 2016-05-11 17:55:02 UTC
The screencast does not exactly follow the steps in comment #6. In the screencast a Xamarin.Forms project has been created instead of just a PCL project. The Xamarin.Forms PCL project has extra references for Forms which mean the bug would not happen.
Comment 11 Matt Ward 2016-05-11 18:58:12 UTC
Those steps do not follow the steps in comment #6. There is no iOS project mentioned in the steps in comment #6.
Comment 13 Matt Ward 2016-05-12 17:13:21 UTC
Not sure what to suggest. If you cannot find a build just before (i.e. something like then maybe the bug was not in build 9. If you cannot reproduce it in the latest version by following the steps in comment #2 or as described in the original bug report by updating Xamarin.Forms then I would say the problem is fixed.