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;
mh
(marc hoffman)
January 29, 2019, 12:38pm
3
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.
mh
(marc hoffman)
January 29, 2019, 3:23pm
5
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
mh
(marc hoffman)
January 29, 2019, 5:54pm
7
Hm, yeah, but that entry in the .deps is about the package, not the assembly, afaict…
mh
(marc hoffman)
January 29, 2019, 8:05pm
8
Fixed, along with a bunch of other minor improvements to the version selector, and improvements for Gradle references too.
1 Like
mh
(marc hoffman)
January 29, 2019, 8:38pm
10
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.
The only documentation I can find is here
# Runtime Configuration Files
The runtime configuration files store the dependencies of an application (formerly stored in the `.deps` file). They also include runtime configuration options, such as the Garbage Collector mode. Optionally they can also include data for runtime compilation (compilation settings used to compile the original application, and reference assemblies used by the application).
**Note:** This document doesn't provide full explanations as to why individual items are needed in this file. That is covered in the [`corehost` spec](corehost.md) and via the `Microsoft.Extensions.DependencyModel` assembly.
## What produces the files and where are they?
There are two runtime configuration files for a particular application. Given a project named `MyApp`, the compilation process produces the following files (on Windows, other platforms are similar):
* `MyApp.dll` - The managed assembly for `MyApp`, including an ECMA-compliant entry point token.
* `MyApp.exe` - A copy of the `corehost.exe` executable.
* `MyApp.runtimeconfig.json` - An **optional** configuration file containing runtime configuration settings.
* `MyApp.deps.json` - A list of dependencies, as well as compilation context data and compilation dependencies. Not technically required, but required to use the servicing or package cache/shared package install features.
The `MyApp.runtimeconfig.json` is designed to be user-editable (in the case of an app consumer wanting to change various CLR runtime options for an app, much like the `MyApp.exe.config` XML file works in .NET 4.x today). However, the `MyApp.deps.json` file is designed to be processed by automated tools and should not be user-edited. Having the files as separate makes this clearer. We could use a different format for the deps file, but if we're already integrating a JSON parser into the host, it seems most appropriate to re-use that here. Also, there are diagnostic benefits to being able to read the `.deps.json` file in a simple text editor.
**IMPORTANT**: Portable Applications, i.e. those published without a specific RID, have some adjustments to this spec which is covered at the end.
## File format
This file has been truncated. show original
And what I presume is the source code for DependencyContext doesn’t appear to have any documentation.
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace Microsoft.Extensions.DependencyModel
{
public class DependencyContext
{
#if !NETSTANDARD1_3
private static readonly Lazy<DependencyContext> _defaultContext = new Lazy<DependencyContext>(LoadDefault);
#endif
public DependencyContext(TargetInfo target,
CompilationOptions compilationOptions,
IEnumerable<CompilationLibrary> compileLibraries,
IEnumerable<RuntimeLibrary> runtimeLibraries,
This file has been truncated. show original
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.
mh
(marc hoffman)
January 31, 2019, 4:02pm
14
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": {
}
}
},
mh
(marc hoffman)
February 1, 2019, 6:55pm
16
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)
mh
(marc hoffman)
February 5, 2019, 7:31pm
18
<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
mh
(marc hoffman)
February 5, 2019, 9:06pm
20
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).