Missing copy local in reference


(JohnMoshakis) #1

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


(JohnMoshakis) #2

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)


(marc hoffman) #3

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…


(JohnMoshakis) #4

Yes I think thats it.

Carter 3.10.0 references newtonsoft 12.01 and some aspnetcore references reference 10.0.1


(marc hoffman) #5

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.


(marc hoffman) #6

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!?


(JohnMoshakis) #7

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.


(marc hoffman) #8

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


(JohnMoshakis) #9

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 ?


(marc hoffman) #10

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:


(marc hoffman) #11

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


(JohnMoshakis) #12

Thanks. Sorry whats the test case for ?


(marc hoffman) #13

For:

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


(marc hoffman) #14

New build is up.


(JohnMoshakis) #15

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


(marc hoffman) #16

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?


(Carlo Kok) #17

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


(marc hoffman) #18
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…


(marc hoffman) #19

Fixed.


(JohnMoshakis) #20

What was the issue ?