Missing copy local in reference

Hi,

I added Carter to a net console app and it wont run because newtonsoft which is a reference hasnt got copy local


Some of the carter references have a copy local, so Im not sure if I should add the reference myself.

Cheers,
John

If i add the reference at runtime I get

Unhandled Exception: System.InvalidOperationException: Cannot find library information for Newtonsoft.Json/12.0.1
at Microsoft.Extensions.DependencyModel.DependencyContextJsonReader.CreateLibrary(TargetLibrary targetLibrary, Boolean runtime, Dictionary2 libraryStubs) at Microsoft.Extensions.DependencyModel.DependencyContextJsonReader.<>c__DisplayClass20_0.<CreateLibraries>b__0(TargetLibrary property) at System.Linq.Enumerable.SelectListIterator2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Linq.Enumerable.CastIterator[TResult](IEnumerable source)+MoveNext() at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items) at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 so

This is the sample

CarterHelloWorldWebApp.zip (781.8 KB)

Curious. Coy Local should propagate down into all dependencies, but from the color, it looks like the Json package is also pulled in from something else beside the Carter ref, and thatā€™s probably the problem (Iā€™ll check tomorrow, the fix will probably be to also propagate CopyLocal for references already added by something elseā€¦

Yes I think thats it.

Carter 3.10.0 references newtonsoft 12.01 and some aspnetcore references reference 10.0.1

Yeah, if the main runtime package pulls it in, it wonā€™t be set to copy local (else, everything would be copy local). this seems the correct behavior, Iā€™m. to sure how handling this different would be feasible.

Reproduced that the project failed on Resolve w/o an error (as the other thread hinted at); thatā€™s a bug, fixed now and your project builds for me. Fix isn;t in time for 2363 which is out now, but Iā€™ll do a new build for you i a bit.

What confuses me is that in have two bug reports for you, using the same test case project, one says ā€œproject doesnt buildā€ (fixed as discussed), and the other says it fails with a runtime error on a missing .dll.

How could get the the latter, of the project failed to build!?

It went like this

  1. Added Carter 3.11.0 which is newtonsoft >=12.01
  2. I ran the exe and it complained newtonsoft wasnt present
  3. I added the 12.01 reference myself but it still complained it couldnt run
  4. I then noticed Carter 3.10.0 had newtonsoft >10.03
  5. I changed the carter reference to 3.10
  6. I also changed the Newtonsoft reference to [11.0.2] This is the lowest that microsoft.aspnetcore.app wants.
  7. When I run the exe is still complaining about trying to find newtonsoft 12.01

It looks like ebuild is still picking up newtonsoft 12.01 because carter 3.11 is installed so it picked that one. I dont think it should do that because Ive specified [11.0.2] of newtonsoft

  1. I changed the carter reference to [3.10.0]
  2. The application runs
  3. If I look at the newtonsoft reference in Fire for Carter its still saying 12.01 but I looked at the build log and it used 11.01

I still believe that any nuget references I add should add [] around the version so its more predictable.
Most of the time Ive been editing the elements file myself and doing that.

Probably should, when specifying a version, yeah. will change.

I think I worked where this comes from

Unhandled Exception: System.InvalidOperationException: Cannot find library information for Newtonsoft.Json/12.0.1
at

Building a project with the lowercase one adds a newtonsoft entry to the libraries section of deps.json file. The uppercase one doesnt and when you run the app you get that exception.

I think I reported that case issue in the dialog before but I cant find it.

I think the lowercase one comes from the libraries/application support/remobjects software/ebuild/packges/nuget/newtonsoft.json/11.0.2

I actually havent got 11.0.2 in my nuget folder so I wouldnt expect the project to build ?

It seems to pull it straight from the cache. Is it meant to do that ?

Probably, yes, the cache uses now all lowercase folder names, as thats what MSā€™s own cache does too. I changed that so we can use it interchangeably in the .dev.json file.

You tell me. the build output would tel you what reference itā€™s using? maybe it got upgraded?

Iā€™m not sure what you mean by that?

my guess whats happening is this: some name checks in EBuild are (thats a bug I guess) not properly case insensitive. the main package pulls in ā€œNewtonsoft.Jsonā€, and then your own reference is ā€œnewtonsoft.jsonā€, and due to the case difference, it gets treated as different package, pulled in again, and added to the reps (dependencies from the main package do not get added there, nor should they be).

Iā€™ll try and fix that (your project as a testcase would be appreciated), but it wonā€™t fix your problem, because then weā€™ll have NewtonSoft.json not go into .deps file at all. No idea why it should.

God, what a f**king mess Microsoft has made here. :frowning:

Iā€™ve fixed the case issue; Iā€™ll send you a new version when itā€™s built (a full new Fire build, for the other thread, will be later in the day). Will be curious to see how it behaves now, also, test case still appreciated for the second part of the issue

Thanks. Sorry whats the test case for ?

For:

assuming thats still a problem for you with the new version.

New build is up.

NewtonCaseConsoleApplication.zip (589.6 KB)

This is the testcase for the casing issue. deps.json is missing the newtonsoft entries in the libraries section.
If I run this I get

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly ā€˜Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeedā€™. The located assemblyā€™s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Abort trap: 6

Having the package in library or not makes no difference to me, ki always get

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I get this whether the reference is copy-local or not (and note, its a different error than what we had before. this is not a missing .dll per se ā€” it finds the .dll, it just doesnā€™t like it, for some reason.

@ck, any ideas?

this probably needs one of those version rewrites. Vresion range [0ā€¦x] -> Exact version. the one you have isnā€™t 12.0

Reference: /Users/mh/Library/Application Support/RemObjects Software/EBuild/Packages/NuGet/newtonsoft.json/12.0.1/lib/netstandard2.0/Newtonsoft.Json.dll

and thatā€™s the version it copy-localsā€¦

Fixed.

1 Like

What was the issue ?