Cysharp / ZLogger

Zero Allocation Text/Structured Logger for .NET with StringInterpolation and Source Generator, built on top of a Microsoft.Extensions.Logging.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NuGet Clone failure in Unity With dotnet 4.8.1

Reag opened this issue · comments

Currently, if you follow the install instructions for Unity (2022.3.x) project set to .Net Standard 2.1, it will function as expected.

However, if you have the project set to .Net Framework, the ZLogger NuGet is configured to deliver an incorrect version of the Microsoft.Bcl.AsyncInterfaces. This leads to a compile error, as the ZLoggerUnityDebugLoggerProvider cannot compile, as the interface IAsyncDisposable is in both Microsoft.Bcl.AsyncInterfaces and mscorlib (System).

There is a work around, setting your project temporarily to .Net Standard 2.1 then doing the NuGet Restore, but this will cause huge problems in automated pipelines

Thank you. Due to the somewhat special of Unity's .NET Framework and .NET Standard 2.1, there can be inconsistencies with definitions on NuGet.
Does this issue with NuGetForUnity match what you're referring to?
GlitchEnzo/NuGetForUnity#621
Please give a +1(and comment) to this, or it might be necessary to open a new issue.

That appears to be the cause, yes.

[edit]: It might be a good idea to provide an optional UPM git url for the NuGet dependencies for the ZLogger in Unity. Perhaps a small repo that just contains the required DLLs for the ZLogger's Unity implementation. That way, a user could get the package without having to deal with the frankly annoying process of trying to use NuGet for Unity. Its more work, but it would allow you to have full control of the DLLs and their delivery. Plus, its always good to have options that don't involve a 3rd party package manager

In the future, we intend to move Cysharp's extensive library of dependent DLLs to the NuGet base.
Providing our own resolution DLLs would undermine such global dependency resolution.
There are various approaches such as OpenUPM and UnityNuGet (not NuGetForUnity), but I believe that the official Microsoft NuGet is the best registry for non-Unity dependent packages.

Would it be possible for you to add the full ZLogger, along with dependencies, to UnityNuGet? From what I've read, you would have to make a PR with references to the dependencies. As it stands right now, I have to manually add all the DLLs to my repo in order for my automated build pipeline to work correctly. If I had an alternative, that would be amazing, as I could use NuGet as its intended to be used.

Apologies for bumping this dead issue, as I'm sure there are far more important and interesting things to be working on.

I believe it's better to have a single registry, and NuGetForUnity is what makes that possible in Unity, which is why I support it. Of course, I'm not against trying to register with other registries (though I'm not fond of OpenUPM, I won't refuse to be registered there, also UnityNuGet).