pdevito3 / HeimGuard

🛡 A simple library that allows you to easily manage permissions in your .NET projects.
MIT License
149 stars 11 forks source link

Dependency resolution warning on build #2

Closed hades200082 closed 1 month ago

hades200082 commented 1 month ago

When using Microsoft.AspNetCore.Authorization in .NET 8 the following warnings are logged.

14>Microsoft.Common.CurrentVersion.targets(2401,5): Warning MSB3245 : Could not resolve this reference. Could not locate the assembly "Microsoft.AspNetCore.Authentication". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
14>Microsoft.Common.CurrentVersion.targets(2401,5): Warning MSB3243 : No way to resolve conflict between "Microsoft.AspNetCore.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" and "Microsoft.AspNetCore.Authentication". Choosing "Microsoft.AspNetCore.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" arbitrarily.

Is there any way to resolve this?

pdevito3 commented 1 month ago

any chance you can provide a minimal repro? i'm not able to so far. also fwiw, the error is calling out Microsoft.AspNetCore.Authentication not Microsoft.AspNetCore.Authorization

hades200082 commented 1 month ago

That's because Microsoft.AspNetCore.Authentication 2.2.0 was deprecated when ASP.Net Core 3.0 released.

In my haste I incorrectly assumed Microsoft had replaced it with Microsoft.AspNetCore.Authorization.

See the deprecation notices and details:

My .NET 8 project is using Microsoft.AspNetCore.Authentication.JwtBearer 8.0.7 for authentication.

It looks like Microsoft.AspNetCore.Authentication, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 is "built-in" to .NET 8 "Microsoft.AspNetCore.App" reference (found in C:\Program Files\dotnet\packs\Microsoft.AspNetCore.App.Ref\8.0.7\ref\net8.0\Microsoft.AspNetCore.Authentication.dll on my system)

HeimGuard is a great package and I'd hate to see it get left behind when MS inevitably updates this built-in assembly to no longer be compatible with 2.2.0.

pdevito3 commented 1 month ago

Not sure exactly what you mean by getting left behind? This should just be because heimguard uses 8.0.0 directly and I can just do a release to bump it

hades200082 commented 1 month ago

I think this warning stems from your .NET 8 build referencing Microsoft.AspNetCore.Authorization.Policy 2.2.0 which is also deprecated and references Microsoft.AspNetCore.Authorization 2.2.0 itself.

Microsoft.AspNetCore.Authorization 2.2.0 references Microsoft.AspNetCore.Authentication.Abstractions 2.2.0 and I think this is where the namespace reference to Microsoft.AspNetCore.Authentication is coming from that's causing the warning.

As a side note, Microsoft.AspNetCore.Http 2.2.2 is also deprecated.

pdevito3 commented 1 month ago

Ah, yeah I see, good call. I'll take a look! Open to a PR if you can beat me to it

pdevito3 commented 1 month ago

just pushed a patch with all the packages bumped and i just flat our removed the dated dependency -- honestly must have snuck in from dev as it literally wasn't used anywhere. thanks for the callout!

let me know if you have any issues