When I try to update a .NET 4.5 project to jint 2.10.2 NuGet fails with the following error.
Failed to add reference. The package 'jint' tried to add a framework reference to 'System.Diagnostics.Contracts' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.
Hello, Johan!
Instead of updating the package try uninstall old version of package, and then install new version. In subsequent updates, this error should not occur.
Hello,
I tried to uninstall package and then install a new version but this error still occur.
Also experiencing this issue on a fresh install on net461.
Can you provide some repro steps, with the type of project you are creating, how you are selecting the nuget package.
I'm also experiencing this problem on a fresh install on .net 4.6.1. Environment:
Originally I was using jint version 2.10.0, and upgrading caused this problem. Uninstalling jint and trying a fresh install didn't solve the problem either unfortunately. In both cases I tried from the package manager console as well as the GUI version in VS. Here's the error dump from the package manager console:
Executing nuget actions took 3.54 sec
update-package : Failed to add reference. The package 'jint' tried to add a framework reference to 'System.Diagnostics.Contracts' which was not found in the GAC. This is possibly a
bug in the package. Please contact the package owners for assistance.
At line:1 char:1
+ update-package jint
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
I'm not completely sure, but this might have something to do with this recent change:
https://github.com/sebastienros/jint/commit/9371178b311d63f2ee2479a69d7d6663565d6173
This change involved moving the System.Diagnostics.Contracts dependency from "dependencies" to "frameworkAssemblies".
Unless I'm mistaken, "frameworkAssemblies" refers to assemblies that are in the GAC. So even if we have the System.Diagnostics.Contracts nuget package installed and updated, it doesn't look for it and instead tries to find it in the GAC (and it's not there). Does that sound reasonable?
@samcic The reason is explained here - https://github.com/sebastienros/jint/pull/340
If this is a choice between working on older versions of NuGet or the current version I think it makes more sense to choose the newer.
@marek-benes @samcic Try the following steps:
@appel1 It's not a choice between the old and new version of NuGet, but this update issue 2.10.0 | 2.10.1 -> 2.10.2.
Thanks for your help @Taritsyn . Unfortunately the steps weren't successful (same error). I also made sure all the local files were deleted (in the solution "packages" folder) to make sure there was no trace of the old 2.10.0 install. I saved everything, built everything (build failed because of the missing jint stuff, but that's fine), then restarted VS as admin. I then tried to install jint fresh as a new package (not an update). Same error.
If I run a "gacutil -l" then it shows the System.Diagnostics.Contracts is indeed installed in the GAC, so the error message is rather confusing.
On the nuget reference page nuget reference page it mentions that the elements in "frameworkAssemblies" should be "The fully qualified assembly name". Perhaps culture, publickeytoken and processorarchitecture should be included? Just an idea.
Interestingly, if I create a fresh (bare bones) console app in VS and install jint, it works. I might try the same with fresh solution with an MVC project + test project like I have, to hopefully try to isolate the issue.
@samcic It seems, that this is a error in the NuGet Package Manager. Because these errors occur only .cproj projects in Visual Studio 2015 (in .xproj projects such errors do not occur).
@Taritsyn I assume you mean .csproj rather than .cproj? If so, I created a bare-bones .csproj console app in VS 2015 targeting .net 4.6.1 and the error doesn't occur. I also created a bare-bones .xproj console app and jint installs fine there too.
Additionally, I created a bare-bones asp.net framework web app (mvc, .net framework 4.6.1, not .net core) project with a unit test project. I installed jsint 2.10.0 first, then upgraded to 2.10.2, and it worked fine.
The only time I see the error is in my "big/real" solution involving again an asp.net framework web app (mvc, .net framework 4.6.1, not .net core), with a .csproj unit test project. The error comes up in this solution regardless of whether I'm updating jint or installing it fresh. In this solution I'm often installing and updating other NuGet packages, and I haven't seen this kind of error with any other package.
Given all this I'm not convinced that it's an error with NuGet. I guess the first step would be to find some repro steps for this error that everyone can agree on. So far I'm not able to find repro steps based on a setting up a fresh VS project.
@samcic .csproj - I made a typo.
In this solution I'm often installing and updating other NuGet packages, and I haven't seen this kind of error with any other package.
Most likely, all these packages have been created by using NuGet.exe from a .nuspec file. Jint package was created by using dotnet.exe from a project.json file.
If you think that there is an error in Nuget, please give me a complete repro of the issue, or tell me to just use what @samcic said. I can talk to them directly and some other experts to analyze where it's coming from.
@sebastienros OK
I had the same problem with an older solution with many, many projects in it.
I did NOT have issues when installing the package into a new solution.
In the new solution, Nuget added a reference to:
_C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Facades\System.Diagnostics.Contracts.dll_
In my older solution, I could not reference the above dll without a getting a little warning sign next to it, so I referenced this one instead:
_C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Diagnostics.Contracts\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Diagnostics.Contracts.dll_
The package installed okay then, and everything _appears_ to be okay, but obviously it doesn't feel right :-)
I can't make any sense of it, but I thought adding a few more details to this thread may help.
@dalenewman Referencing the assembly from the GAC folder as you described worked for me as well. Thanks for the information. In my case jint is only being used in a test project (no production code), so I consider this a sufficient solution to my problem.
Another note: after the jint package successfully installed, I was then able to remove that "not feeling right" GAC System.Diagnostics.Contracts reference from the project and everything was still fine. So it almost seems like the reference just needed to be there just for the upgrade. All a bit strange.
Also just experienced this issue.
Same here. Tried to update AngleSharp.Scripting. I know this is more than a MWE but the issue seems to be related to existing / larger repos and does not appear with fresh projects.
Also having this issue. To confirm, the issue only occurs on 2.10.2. 2.10.1 installs absolutely fine.
Targeting .NET 4.6.1
Same issue here:
Failed to add reference. The package 'jint' tried to add a framework reference to 'System.Diagnostics.Contracts' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.
Details :
2.10.1 to 2.10.2.I had same issue in Visual Studio 2015 Update 3, .NET Framework 4.5.1. Tried to install jint v2.10.3 from scratch.
Steps to workaround the issue:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\System.Diagnostics.Contracts.dlljint with nuget package manager, now it works!System.Diagnostics.Contracts.dll from projectClosing as there's a workaround and 3.x shouldn't suffer from this, and that's where development efforts are.
Most helpful comment
I had same issue in Visual Studio 2015 Update 3, .NET Framework 4.5.1. Tried to install jint v2.10.3 from scratch.
Steps to workaround the issue:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\System.Diagnostics.Contracts.dlljintwith nuget package manager, now it works!System.Diagnostics.Contracts.dllfrom project