Dependency names in deps.json

Hi,

This is a piece of deps.json

“targets”: {
“.NETCoreApp,Version=v2.2”: {
“CarterHelloWorldWebApp/1.0.0”: {
“dependencies”: {
“carter”: “3.10.0”
},
“runtime”: {
“CarterHelloWorldWebApp.exe”: {
}
}
},

Would I be right in thinking that the name in the dependencies section is generated from the folder name in the .nuget folder ?

With Carter the foldername is all lower case but the actual assembly is Carter.dll

Carter is making use of the class DependencyContext

This is the source for the carter code

It does this

return library.Dependencies.Any(dependency => dependency.Name.Equals(carterAssemblyName));

Its using it to locate classes.

It wasnt able to find classes until I went into the elements file and changed the nuget reference to match the case of the assembly

<NuGetReference Include=“carter:[3.10.0]”>

I changed this to

<NuGetReference Include=“Carter:[3.10.0]”>

Deps.json is now

".NETCoreApp,Version=v2.2": {
  "CarterHelloWorldWebApp/1.0.0": {
    "dependencies": {
      "Carter": "3.10.0"
    },
    "runtime": {
      "CarterHelloWorldWebApp.exe": {
      }
    }

and my web api starts working.

Cheers,
John

This is a testcase

DependencyContext .zip (1.8 MB)

DependencyContextConsoleApp is the one I created in Visual Studio. The other was created in Fire.

The casing causes the code to raise the exception.

  var context := DependencyContext.Load(&Assembly.GetEntryAssembly());

  var name := typeOf(Carter.CarterExtensions).Assembly.GetName.Name;
  var carterLib := context.RuntimeLibraries.FirstOrDefault(l -> l.Name.Equals(name));

  if (not assigned(carterLib))then
  begin
      raise new Exception('We shouldnt get here');
  end;

I believe it’s lowercase because thats how your reference is spelled

    <NuGetReference Include="carter:[3.11.0]">
      <Private>True</Private>
    </NuGetReference>

Fix that to uppercase and it looks fine?

(I have an open issue that Fire/Water currently use the cache folder names (which are lowercase) do display references in Add References, which is a new side effect from having to restructure the cache folder to match Microsoft’s layout. that’ll be fixed soonish).

The example works with the case change. I dont know if it does anything special or just always uses upper case.

Well, if there’s lowercase everywhere, the build chain has n way to determine what the “proper” case could be. I can only go by what’s in the reference.

The assembly isnt lower case thats why I was wondering if you used the name of the folder and should be using the assembly name instead.

Carter instead of carter

Hm, yeah, but that entry in the .deps is about the package, not the assembly, afaict…

Fixed, along with a bunch of other minor improvements to the version selector, and improvements for Gradle references too.

1 Like

Can I have a new build ?

Maybe; a new Fire build is a bit more involved than shopping it off omg our CI system, and it’s getting evening. I’ll try.

Up.

1 Like

The only documentation I can find is here

And what I presume is the source code for DependencyContext doesn’t appear to have any documentation.

Could this one be looked into ?

I dont know if its a problem with the elements deps files or how its being used in carter. It would be nice to be able to add the reference and not have to modify the elements file.

What part? I had considered this solved as per my last reply (it uses the case from the project now). What’s the remaining/new problem?

It shows up as lowercase in the deps file

".NETCoreApp,Version=v2.2": {
  "ConsoleApplication/1.0.0": {
    "dependencies": {
      "carter": "3.11.0"
    },
    "runtime": {
      "ConsoleApplication.exe": {
      },
      "Echoes.dll": {
      }
    }
  },

Even with the reference being in the correct case? can you send me your current project as is (because for me, that fixed it).

The casing hasnt changed

ConsoleApplication2.zip (1.3 MB)

    <NuGetReference Include="carter:[3.11.0]">
      <Private>True</Private>
    </NuGetReference>

I feel like I’m on candid camera here…

That’s what I get if I use Fire to add a reference

It needs to be Carter:[3.11.0] so that deps file ends up with the right case

“.NETCoreApp,Version=v2.2”: {
“ConsoleApplication/1.0.0”: {
“dependencies”: {
“Carter”: “3.11.0”
},
“runtime”: {
“ConsoleApplication.exe”: {
},
“Echoes.dll”: {
}
}
},

and the code in the test case works

Yes. Which is what I told you two weeks ago.

And that too has been fixed a week ago, I even sent you a new build with the fix (but I also mentioned that that was a known problem when I told you to change the case).