Skip to content

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

@ImrePyhvel

Description

@ImrePyhvel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions