Bug 22805 - Removing references and replacing them with NuGet packages does not refresh assembly cache?
Summary: Removing references and replacing them with NuGet packages does not refresh a...
Status: NEW
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Mac OS
: --- minor
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-09-10 02:11 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2014-11-24 15:18 UTC (History)
3 users (show)

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


Attachments
Test case (11.33 KB, application/zip)
2014-09-10 02:11 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Diagnostic MSBuild ouput (27.65 KB, application/zip)
2014-09-10 02:12 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details


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 22805 on GitHub or 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: GitHub Markdown or 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.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Brendan Zagaeski (Xamarin Team, assistant) 2014-09-10 02:11:02 UTC
Created attachment 7978 [details]
Test case

Removing references and then replacing them by adding NuGet packages does not appear to refresh the assembly resolver cache.

Related bug: https://bugzilla.xamarin.com/show_bug.cgi?id=22279

This might be a duplicate of bug 22279. The error messages are a little different in this particular test project. The attached test project does not produce the "Compiler crashed with code : 1" error, but I was able to produce that error using a slightly more complicated project from a user.

My only hesitation in marking it as a duplicate is that the problem described in this bug report can be solved by closing and reopening the project in Xamarin Studio.



## Steps to reproduce

1. Open the attached test case in Xamarin Studio and let NuGet restore the packages.

2. Control-click the "Newtonsoft.Json" reference under "Solution Pad -> References -> From Packages".

3. Select "Delete".

4. Control-click the "Newtonsoft.Json" package under "Solution Pad -> Packages".

5. Select "Remove".

6. Control-click the project name in the Solution Pad, and select "Add -> Add Packages"

7. Install the Json.NET NuGet package.

8. Build the project.


The special thing about the attached test case is that the HintPath for the Newtsonosft.Json reference is set to the "portable-net40" [1] version rather than the "portable-net45" version. Reinstalling the NuGet package at step 7 switches this reference to the default "portable-net45" version.

> [1] ..\packages\Newtonsoft.Json.6.0.5\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll



## Result

The build produces 13 "Error CS0012" errors. Cleaning and rebuilding the project does not stop the errors, but unloading and reloading the project _does_ stop the errors.

Example error:
> Error CS0012: The type
> `System.Collections.Generic.IDictionary`2<string,Newtonsoft.Json.Linq.JToken>'
> is defined in an assembly that is not referenced. Consider adding a
> reference to assembly `System.Runtime, Version=4.0.0.0,
> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' (CS0012)
> (AndroidApp1)



## Workaroud

Close and reopen the project.



## Version information

Xamarin Studio Version 5.3 (build 441)
Git revision: befb6aa1176d37a5f678f4274f340a0159091b7a
Xamarin addins: 6dc7c388e31fdfc8014689839d37de0d4622435c

Mono 3.8.0 ((no/45d0ba1)
GTK+ 2.24.23 (Raleigh theme)

Xamarin.Android 4.16.0 (Business Edition)

Xcode 5.1 (5084), Build 5B130a
Mac OS X 10.9.4
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2014-09-10 02:12:48 UTC
Created attachment 7979 [details]
Diagnostic MSBuild ouput
Comment 2 Mikayla Hutchinson [MSFT] 2014-09-10 11:35:46 UTC
xbuild doesn't seem to be expanding the facades.

My guess is that this has something to do with xbuild's internal dependency caches in the ResolveAssemblyReference task.
Comment 3 James Athey 2014-11-24 15:18:59 UTC
I'm seeing this bug as well, except that unloading and reloading the project or the solution is not fixing the issue. My .csproj references the portable-net45+wp80+win8+wpa81 version of Newtonsoft.Json.

## Version Information

Xamarin Studio Version 5.5.4 (build 15)
Mono 3.10.0 ((detached/92c4884)
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Android Version: 4.20.0.28 (Business Edition)
Mac OS X 10.9.5