Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In NuGet package, .NET Framework and .NET Standard versions of JIL should use the same assembly identity #279

Closed
dsplaisted opened this issue Sep 11, 2017 · 11 comments

Comments

@dsplaisted
Copy link

Currently, the layout of the Jil NuGet package is similar to this:

lib/
    net45/
        Jil.dll
    netstandard1.6
        Jil.Core.dll

IE, the assembly name is different depending on whether you are using the .NET Framework version or the .NET Standard version. This presents a problem when a .NET Framework project references a .NET Standard project which uses Jil. The .NET Standard project will be compiled against Jil.Core.dll, but in the .NET Framework project it will be Jil.dll that is deployed, and at runtime Jil.Core.dll won't be available.

When creating a NuGet package with different versions of a library for different targets, the library should use the same assembly name for each platform, and platforms with "broader" reach (ie .NET Standard) should be "API Compatible" with the more specific versions (ie .NET 4.5).

In order to make this work without breaking code which was compiled against previous versions of the package and Jil.Core.dll, I would suggest creating a version of Jil.Core.dll which has type forwards to Jil.dll for all the types that were previously in Jil.Core.dll. Then deploy that type-forward version of Jil.Core in both the lib/net45 and lib/netstandard1.6 folders of the package.

@andybn-zz
Copy link

We have the same problem ... Is there any solution?

@xemicalas
Copy link

Can this issue be more prioritized? We are facing it too..

@ShamsulAmry
Copy link

Ditto

@NickCraver
Copy link
Collaborator

We hit this in the Stack Overflow port to .NET Core as well. I took today and did all the work here - PR incoming shortly.

NickCraver pushed a commit to NickCraver/Jil that referenced this issue Jun 7, 2018
This does a lot of things. The root cause is issue kevin-montrose#279, because Jil.dll and Jil.Core.dll differ anything restoring from a netstandard library that depends on Jil being restored to a net4x project go boom. Because the netstandard lib referenced Jil.Core, with a different signature. It cannot be fixed on the user end.

But hey, multi-targeting works now...so I upgraded Jil to use it. This commit:
- Drops JilCore and JilCore.Tests (folded into Jil and JilTests)
- Drops \packages (uses <PackageReference>)
- Adds a netstandard2.0 build (far fewer references and less baggage for most users)
- Moves testing to xunit (makes dotnet xunit available)
- Tests all 3 releases
- Adds a build.cmd (runs tests, creates packages in /.nupkgs/)
- Does *not* modify versioning, still manual.

To build, just run build.cmd.
@NickCraver
Copy link
Collaborator

I've opened PR #304 to fix this mismatch up in the next release.

NickCraver added a commit to StackExchange/StackExchange.Utils that referenced this issue Jun 8, 2018
This fixes restore and signature issues on net4x platforms, see kevin-montrose/Jil#279 for details and kevin-montrose/Jil#304 for the fix.
@NickCraver
Copy link
Collaborator

Jil 2.16.0 has been released and I've confirmed this all behaves as expected now.

For anyone that hit this: an upgrade to 2.16.0 should fix you up. There's also now a netstandard2.0 build with fewer dependencies to boot.

@andreycha
Copy link

I can confirm that 2.16.0 fixes the issue. Thanks a lot @NickCraver !

@NickCraver
Copy link
Collaborator

Closing this out to tidy up - it's all fixed up now :)

@Vaccano
Copy link

Vaccano commented Mar 10, 2020

This fix causes a conflict when an application uses 2 NuGets that use this library when:

  1. One of the NuGets depends on a pre-change version (2.15.4 for me)
  2. Another that depends on a post change version (2.17 for me)

Basically, the pre-change dependency is looking for a jil.core assembly and cannot find it in the newer version. (See this stack overflow question for details: https://stackoverflow.com/questions/60609571/nuget-package-is-looking-for-exact-version).

I have not found a way around it at this time. (Aside from contacting the package maintainers and asking them to upgrade. But that is a timeline killer.)

@NickCraver
Copy link
Collaborator

@Vaccano The bad news is: tt was an issue either way. If another package was netstandard and one was net4x, it'd also have errored (that's how we hit it in the Stack Overflow port). It's unfortunate that you have 2 chains in the path here, but there was no other way out of the problem. It was a bad bug...that had to be fixed.

Which package are you hitting against on an old version? It's possible I could poke something there.

@Vaccano
Copy link

Vaccano commented Mar 10, 2020

@NickCraver I appreciate the offer for help! However it is an internal team that built the package that is using the 2.15.4 version.

I am already leaning on them to update the dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants