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:
-
Create new .Net Framework 4.8.1 project, console works.
-
Add nuget package: Microsoft.Owin.Security.Authorization.WebApi 1.2.2.4
-
enable xml serialization assembly generation : <GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
-
Add [ResourceAuthorize] to any class, i.e. Program
-
Build (success) - base case all good.
-
Upgrade nuget package: Microsoft.AspNet.WebApi.Core 5.2.3 -> 5.2.9 (or 5.3.0)
-
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.