Skip to content

Interop source generators failing build in dotnet/runtime when latest SDK is installed #92655

@ericstj

Description

@ericstj

Description

When building for older frameworks the latest interop source generator is used, which ends up forcing the latest shared library Microsoft.Interop.SourceGeneration.dll while still using older source generators. This makes the older source generators break if there are breaking changes to the internal Microsoft.Interop.SourceGeneration.dll.

Reproduction Steps

Build C:\src\dotnet\runtime\src\libraries\Common\tests\TestUtilities\TestUtilities.csproj

Expected behavior

Builds successfully

Actual behavior

Build fails with

CSC : error CS8784: Generator 'VtableIndexStubGenerator' failed to initialize. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'TypeLoadException' with message 'Could not load type 'Microsoft.Interop.TargetFramework' from assembly 'Microsoft.Interop.SourceGeneration, Version=42.42.42.42, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.'

Regression?

Yes,

Known Workarounds

No response

Configuration

No response

Other information

I attempted to fix this in #92648 before fully understanding the problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions