dotnet / dotnet/extensions

Microsoft.Extensions.Telemetry.Abstractions nuget package is missing the buildTransitive/netstandard2.0 folder

Open
#7,416 3 comments 0 reactions 0 assignees View on GitHub
bug needs-area-label untriaged
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

### Description

The build and published nuget package supports net462, netstandard2.0, and the stanrdard net8.0, net9.0, and net 10.0 TFMs.
However, the package does not include the buildTransitive/netstandard2.0 folder and associated .targets file.
Using this on a class library targeting netstandard results in problems with conflicting source generators since the `DisableMicrosoftExtensionsLoggingSourceGenerator` property is not injected into the project.

### Reproduction Steps

Create a netstandard2.0 class library.
Install `Microsoft.Extensions.Telemetry.Abstractions`
Try and use the `LoggerMessageAttribute`.
You will get an error about ambiguous methods and partial methods cannot have multiple implementations.

### Expected behavior

You should be able to use `LoggerMessageAttribute` etc. to get the enhanced version of the source generator without conflicts.

### Actual behavior

The original source generator from `Microsoft.Extensions.Logging.Abstractions` conflicts and you get error messages and it won't compile.

### Regression?

This appears to be the case in all the packages I've looked at from 8.0.0 thru 10.4.0

### Known Workarounds

You can manually add the missing property to the class library project.

```xml true
```

### Configuration

Not really applicable but a netstandard2.0 class using net10 sdk.

### Other information

There is some code in the project file which I think is meant to make the build engine add the transitive file but it doesn't appear to work.

https://github.com/dotnet/extensions/blob/b797b53993672eae537cf2cebe6ad3cf58c507e6/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Microsoft.Extensions.Telemetry.Abstractions.csproj#L35-L44

The `lib/netstandard2.0` folder exists and the dll is there.

https://nuget.info/packages/Microsoft.Extensions.Telemetry.Abstractions/10.4.0

There does seem to be some mixing of stuff in the .targets/.props files. There is no net9.0 or net10.0 buildTransitive folder either (I assume it falls back to the net8.0 version).
The net462 version has the property in the .targets file, not a .props file, and the target that removes the analyser is missing there.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.