0

I have a class library that I'm publishing as a nuget package.

However, when I try to consume this package in a demo app, I get this error when I try to use it.

System.MissingMethodException: Method not found: 'Hypermedia.Configuration.FieldBuilder`1<!0> Hypermedia.Configuration.DelegatingContractBuilder`2.RenameFieldUsingJsonPropertyName(System.String)'.
   at DISCOSweb_Sdk.Mapping.JsonApi.DiscosObjects.DiscosObjectContractBuilder.WithDiscosObject(IBuilder builder)
   at DISCOSweb_Sdk.Mapping.JsonApi.DiscosObjectResolver.CreateResolver()
   at DISCOSweb_Sdk.Clients.DiscosClient.GetMultiple[T](String queryString)
   at DISCOSweb_demo_app.Pages.SimpleFetching.GetMultiple.UpdateModel(Type t) in /home/james/repos/DISOSweb-sdk/src/demo-app/Pages/SimpleFetching/GetMultiple.cs:line 35

So, the RenameFieldUsingJsonPropertyName() method is actually located in a submodule of the SDK repo and is included with a project reference.

So, what I suspect is going on is that the nuget build isn't grabbing the code from the referenced projects.


    <ItemGroup>
        <ProjectReference Include="..\..\..\vendor\Hypermedia\Src\Hypermedia.JsonApi.Client\Hypermedia.JsonApi.Client.csproj" />
        <ProjectReference Include="..\..\..\vendor\Hypermedia\Src\Hypermedia\Hypermedia.csproj" />
    </ItemGroup>

If this is the case, I'd imagine I could publish that submodule on nuget too and then reference that in the SDK to fix the problem. However, my submodule is a fork of someone else's package with some patches (including adding this method) so I don't really want to do that, especially since I have PRs in with upstream.

Is there any way to force the nuget build to grab all of the project references and include them? It's also entirely possible that I'm barking up the wrong tree here.


NB: I have seen this answer, but the flag mentioned doesn't seem to exist in dotnet pack

ScottishTapWater
  • 3,656
  • 4
  • 38
  • 81

1 Answers1

0

Two ideas came to my mind when reading your question:

  1. Stick to nuget pack instead of dotnet pack → as you already mentioned, the idea of newer NuGet packages build with dotnet pack is to have multiple packages instead of a single package with multiple assemblies.
    Maybe you can play around with the <files> element in .nuspec: since you're already building the other projects, you could add references to the dlls.
  2. According to the Microsoft docs, you could try this:
<ItemGroup>
    <ProjectReference Include="..\..\..\vendor\Hypermedia\Src\Hypermedia.JsonApi.Client\Hypermedia.JsonApi.Client.csproj">
        <IncludeAssets>all</IncludeAssets>
    </ProjectReference>
    <ProjectReference Include="..\..\..\vendor\Hypermedia\Src\Hypermedia\Hypermedia.csproj">
        <IncludeAssets>all</IncludeAssets>
    </ProjectReference>
</ItemGroup>

Disclaimer: I didn’t test either one.

mu88
  • 4,156
  • 1
  • 23
  • 47
  • 2 didn't work and for some reason the `nuget` binary for arch doesn't seem happy. I ended up just uploading nuget packages of my fork – ScottishTapWater Jun 09 '22 at 10:30