0

I wanted to add JsonConvert to the project. I'm very new to .NET development, but I thought it'd be similar to apt-get. Install package, start working.

I open Nuget, do Package-Install NewtonSoft.Json

It rapidly uninstalled a lot of packages and then reinstalled newer versions of these without prompting.

Now the project is broken. Attempting to load the dev version of the website results in.

"Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified."

I then tried to run Update-Package -restore... hoping that somehow it would rollback things to the way they were before it started to get fancy on our installation. No luck.

Update 3:

Adding remove-dependencies and force to Uninstall-Package, finally made it possible to remove UmbracoCms.Core.7.5.2 installation that NuGet had spontaniously added. The problem is now to install UmbracoCms.Core.7.2.1 because it doesn't seem that you can do Package-Install to add it.

PM> Install-Package UmbracoCms.Core.7.2.1
Install-Package : Unable to find package 'UmbracoCms.Core.7.2.1'
At line:1 char:16
+ Install-Package <<<<  UmbracoCms.Core.7.2.1
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManag 
   ement.PowerShellCmdlets.InstallPackageCommand

Update 4:

Found out you have to specify versions using -version. This resulted in the following.

PM> Install-Package UmbracoCms.Core -version 7.2.1
Attempting to gather dependency information for package 'UmbracoCms.Core.7.2.1' with respect to project 'Website', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for package 'UmbracoCms.Core.7.2.1' with DependencyBehavior 'Lowest'
Install-Package : Unable to find a version of 'Microsoft.AspNet.Mvc' that is co
mpatible with 'ClientDependency-Mvc 1.8.0 constraint: Microsoft.AspNet.Mvc (>= 
4.0.20710)', 'Microsoft.AspNet.Mvc.FixedDisplayModes 5.0.0 constraint: Microsof
t.AspNet.Mvc (>= 5.0.0)', 'UmbracoCms.Core 7.2.1 constraint: Microsoft.AspNet.M
vc (>= 4.0.30506 && < 5.0.0)'.
At line:1 char:16
+ Install-Package <<<<  UmbracoCms.Core -version 7.2.1
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Update 5:

Officially not sure what to do... I've never experienced anything like this in my entire life of programming.

I was just going to sit down, do some light changes to the frontend and had couldn't find JsonConvert... in my naivete I installed NewtonSoft.Json with Nuget, then it intalled a new version of UmbracoCms... without prompting! Then I manage to remove it... now I can't install the older version.

Update 6:

Talking around on the web has told me that this is the huge steel-trap waiting for anyone using NuGet, and the developers themselves have admitted that its broken by design. It was a mistake for me to install NewtonSoft.Json... now I'm not sure how to reinstall the right version of UmbracoCms on the one solution I deleted it from.

I'll tell my boss development time has been extended due to this.

Leonhard Printz
  • 355
  • 2
  • 16

2 Answers2

1

NewtonSoft.Json is a dependency of Umbraco and was already part of your solution - but in a specific version compatible with Umbraco. What you've ended up doing is upgrade NewtonSoft.Json which triggered uninstalls or upgrades for each package with a dependency to it (uninstalls when newer version isn't supported).

Should be solvable by uninstalling NewtonSoft.Json and reinstalling UmbracoCms, I think.

Jannik Anker
  • 3,320
  • 1
  • 13
  • 21
  • Thank you for the answer. I've attempted to do only to get this. "Attempting to gather dependency information for package 'Newtonsoft.Json.9.0.1' with respect to project 'Website', targeting '.NETFramework,Version=v4.5' Resolving actions to uninstall package 'Newtonsoft.Json.9.0.1' Uninstall-Package : Unable to uninstall 'Newtonsoft.Json.9.0.1' because 'Micros oft.AspNet.WebApi.Client.5.2.3, UmbracoCms.Core.7.5.2' depend on it" – Leonhard Printz Aug 25 '16 at 10:27
  • Get what? You've tried restoring, I suggest removing and installing. That's not the same thing. Also I don't see the UmbracoCms package mentioned anywhere in the log, have you by chance only installed UmbracoCms.Core? – Jannik Anker Aug 25 '16 at 10:30
  • As far as I can see in our web.config the Umbraco version was supposed to be: – Leonhard Printz Aug 25 '16 at 10:32
  • Oh, sorry, it rolled back the uninstall (and added the packages back in), I misread that. Basically you want to start all over, so maybe try uninstalling UmbracoCms first and then (if it's still there) uninstall NewtonSoft.Json? – Jannik Anker Aug 25 '16 at 10:43
  • Nothing happens when I enter Package-Uninstall UmbracoCms, or Package-Install UmbracoCms, with or without version numbers. I get no error messages, nor any indication that anything is happening. Is this expected behavior? – Leonhard Printz Aug 25 '16 at 10:45
  • Try Uninstall-Package UmbracoCms.Core then? :-s – Jannik Anker Aug 25 '16 at 10:47
  • Argh, more packages! I don't know, then. Sorry. – Jannik Anker Aug 25 '16 at 10:54
1

Once I faced similar issue when I upgraded NewtonSoft.Json from 7.0.1 to latest version using NuGet. It was weird, it was asking for some licence when I ran the application. So I moved back to 7.0.1 and have stuck to it since then.

I am listing step I performed to refresh all packages in my solution. There might be a better way, but this worked for me.

  1. Removed everything from packages folder.
  2. Cleaned nuget cache using all options I could find. See
  3. Verified if all packages and versions listed in package.config are correct.
  4. I had nugetPowerTools installed. So, enabled NuGet Package Restore.
  5. VS restart.
  6. Build solution, all missing packages were downloaded.

HTH.

Community
  • 1
  • 1
wonderbell
  • 1,126
  • 9
  • 19