-
-
Notifications
You must be signed in to change notification settings - Fork 547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to add reference to System.Diagnostics.Contracts #341
Comments
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, |
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:
|
I'm not completely sure, but this might have something to do with this recent change: 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? |
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 |
@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.
Most likely, all these packages have been created by using |
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. |
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. |
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. |
@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. |
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 Targeting |
Same issue here:
Details :
|
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:
|
Closing as there's a workaround and 3.x shouldn't suffer from this, and that's where development efforts are. |
When I try to update a .NET 4.5 project to jint 2.10.2 NuGet fails with the following error.
The text was updated successfully, but these errors were encountered: