Skip to content

When transitively including both Microsoft.Extensions.Telemetry.Abstractions and Microsoft.Extensions.Logging.Abstractions, both logging source generators get installed only for .NET 6 and 7 targets #4565

@mkane91301

Description

@mkane91301

Description

At least when multi-targeting, if you include one package that transitively includes Microsoft.Extensions.Telemetry.Abstractions and another that transitively includes Microsoft.Extensions.Logging.Abstractions (for 8.0 RC2), both Microsoft.Extensions.Logging.Generators and Microsoft.Gen.Logging are installed for net6.0 and net7.0 targets (but not net462 or net8.0), resulting in two implementations of each partial logging method, causing CS0757 in the generated code and CS0121 where the logging method is called.

Reproduction Steps

Target .NET 6 or 7 (or both).

Install Microsoft.Extensions.Resilience (to transitively include Microsoft.Extensions.Telemetry.Abstractions) and Microsoft.Extensions.Caching.Memory (to transitively include Microsoft.Extensions.Logging.Abstractions).

Create a logging method using the LoggerMessage attribute.

Call the logging method.

Expected behavior

Only one implementation of the logging method is generated.

Actual behavior

Two implementations of the logging method are generated.

Regression?

Never tried this before.

Known Workarounds

Haven't found a workaround.

Configuration

This is happening building with the 8.0 RC2 SDK on Windows 11 (x64) in Preview 3 of VS 17.8.

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions