DavidParks8 / Owin-Authorization

Backport of Asp.Net core's policy based authorization to Asp.Net 4
Other
60 stars 16 forks source link

Upgrading `Microsoft.AspNet.WebApi.Core` causes sgen.exe to fail with "Could not load file or assembly 'System.Web.Http, Version=5.2.3.0 .." #118

Open ImrePyhvel opened 9 months ago

ImrePyhvel commented 9 months ago

Upgrading Microsoft.AspNet.WebApi.Core causes SGEN to get confused about dependencies and fail build. When xml serialization is configured as "auto", then debug build suceeds and Release build will fail. When [ResourceAuthorize] is placed on method, then build succeeds, if on class, it fails.

What's happening? How to make [ResourceAuthorize]work on class level after WebApi.Core upgrade?

Repro steps:

  1. Create new .Net Framework 4.8.1 project, console works.

  2. Add nuget package: Microsoft.Owin.Security.Authorization.WebApi 1.2.2.4

  3. enable xml serialization assembly generation : <GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>

  4. Add [ResourceAuthorize] to any class, i.e. Program

  5. Build (success) - base case all good.

  6. Upgrade nuget package: Microsoft.AspNet.WebApi.Core 5.2.3 -> 5.2.9 (or 5.3.0)

  7. Build (error)

Actual result

1>SGEN : error : Could not load file or assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 1> 1>Build FAILED.

Expected result:

Build should succeed.