Repository navigation
Description
Description
Right after I added this package reference to my SDK-style project targeting net8.0-windows for my WPF program I started to get these errors.
Reproduction Steps
A new WPF application targeting .NET 8, using the following packages:
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Resilience" Version="8.2.0" />
Expected behavior
No error.
Actual behavior
Severity Code Description Project File Line Suppression State
Error CS0757 A partial method may not have multiple implementing declarations Program G:\home\dev\csharp\temp\src\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs 13 Active
Regression?
Known Workarounds
None barring not using the package.
Configuration
.NET SDK:
Version: 8.0.200
Commit: 438cab6a9d
Workload version: 8.0.200-manifests.e575128c
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.200\
.NET workloads installed:
[maui-windows]
Installation Source: VS 17.9.34616.47
Manifest Version: 8.0.6/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.6\WorkloadManifest.json
Install Type: FileBased
[android]
Installation Source: VS 17.9.34616.47
Manifest Version: 34.0.52/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.52\WorkloadManifest.json
Install Type: FileBased
[ios]
Installation Source: VS 17.9.34616.47
Manifest Version: 17.2.8004/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.2.8004\WorkloadManifest.json
Install Type: FileBased
[maccatalyst]
Installation Source: VS 17.9.34616.47
Manifest Version: 17.2.8004/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.2.8004\WorkloadManifest.json
Install Type: FileBased
Host:
Version: 8.0.2
Architecture: x64
Commit: 1381d5ebd2
.NET SDKs installed:
8.0.200 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Other information
No response
Activity
ZzZombo commentedon Feb 28, 2024
Could somebody at least point to a workaround? This is a blocking issue for us.
RussKie commentedon Feb 29, 2024
There's a conflict of packages similar to the issues that you've already found.
AFAIK, Microsoft.Extensions.Telemetry.Abstractions carries a source generator that replaces a source generator from Microsoft.Extensions.Logging.Generators, and it's doing so via
<DisableMicrosoftExtensionsLoggingSourceGenerator>true</DisableMicrosoftExtensionsLoggingSourceGenerator>MSBuild property.extensions/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/buildTransitive/net6.0/Microsoft.Extensions.Telemetry.Abstractions.props
Lines 2 to 5 in 88d79f7
extensions/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/buildTransitive/net6.0/Microsoft.Extensions.Telemetry.Abstractions.targets
Lines 2 to 15 in 88d79f7
Can you verify Microsoft.Extensions.Telemetry.Abstractions is being referenced by your project? And
_Microsoft_Extensions_Logging_AbstractionsRemoveAnalyzersis being executed?ZzZombo commentedon Feb 29, 2024
Directly or transitively?
Can you explain to me how to do this part?
RussKie commentedon Mar 1, 2024
The easiest way to do both of those is to capture and inspect a binary log. Please see https://msbuildlog.com/ for more information.
Perhaps, try referencing Microsoft.Extensions.Telemetry.Abstractions directly?
ZzZombo commentedon Mar 1, 2024
Adding the package directly had no effect. For other answers please see the screenshot.

RussKie commentedon Mar 1, 2024
You mentioned that your project is targeting net8.0-windows but the screenshot is showing you're consuming net9 packages... Could you please clarify why?
ZzZombo commentedon Mar 1, 2024
It was to see if doing so fixes this issue. Previously I targeted .NET 8.
xakep139 commentedon Mar 7, 2024
Hello @ZzZombo, I was just trying to reproduce the issue but had no luck:

Are there any specific steps I also need to take? I'm using .NET SDK

8.0.200as you mentioned in the post and also tried to repro with the .NET CLI, but it still builds the project just fine:ZzZombo commentedon Mar 12, 2024
@xakep139: this is stripped down project file that still shows the problem for us:
xakep139 commentedon Mar 12, 2024
Okay, you missed the usage of
[LoggerMessage]in your reproduction steps.Here's the minimal repro:
And
Log.cs:xakep139 commentedon Mar 12, 2024
Even if I replace
Microsoft.Extensions.Resiliencereference withMicrosoft.Extensions.Telemetry.Abstractionspackage, it still emits the same errorRussKie commentedon Mar 19, 2024
I've run some local tests and wonder why we we didn't implement the target this way:
This way I was able to build a WPF sample without any additional changes.
@joperezr any thoughts?
RussKie commentedon Mar 29, 2024
@joperezr gentle nudge
xakep139 commentedon Apr 10, 2024
@RussKie, will your target also work on non-WPF projects?
RussKie commentedon Apr 10, 2024
It should work universally. More tests will be required to confirm.
I'm still waiting on @joperezr (we've been busy with other high prio work), but we've aiming to have a resolution for this issue for the .5 release.
xakep139 commentedon May 15, 2024
@RussKie my concern was that
RemoveDuplicateAnalyzerstarget might exist for WPF apps onlyRussKie commentedon May 17, 2024
Yes, you're right. That target is part of the Windows Desktop SDK:

RussKie commentedon May 17, 2024
This should work:
<Target Name="_Microsoft_Extensions_Logging_AbstractionsRemoveAnalyzers" Condition="'$(DisableMicrosoftExtensionsLoggingSourceGenerator)' == 'true'" - AfterTargets="ResolveReferences"> + BeforeTargets="CoreCompile">Tested for a console app, webapi app and for a WPF apps.