Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<!-- This package should replace the "Microsoft.Extensions.Logging.Abstractions" source generator. -->
<Target Name="_Microsoft_Extensions_Logging_AbstractionsRemoveAnalyzers"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that the two targets had the same name was very intentional, as we want to make sure that the targets are replaced such that only one ever runs in a project evaluation. Do we have a repro project where we can clearly see the issue? I'd like to see that to better understand the problem and validate the RCA made here, as I don't think that target naming colissions was the problem.

<Target Name="_Microsoft_Extensions_Telemetry_AbstractionsRemoveAnalyzers"
Condition="'$(DisableMicrosoftExtensionsLoggingSourceGenerator)' == 'true'"
AfterTargets="ResolveReferences">
<ItemGroup>
Expand All @@ -19,7 +19,7 @@
<!-- We have a WPF-specific target because WPF projects generate and compile a temporary project (via "GenerateTemporaryTargetAssembly" target),
and that temp project doesn't have "ResolveReferences" target we expect.
This leads to the runtime's generator not being removed and to a compile-time error CS0757. This additional target resolves the problem. -->
<Target Name="_Microsoft_Extensions_Logging_AbstractionsRemoveAnalyzersWPF"
<Target Name="_Microsoft_Extensions_Telemetry_AbstractionsRemoveAnalyzersWPF"
Condition="'$(DisableMicrosoftExtensionsLoggingSourceGenerator)' == 'true'"
AfterTargets="RemoveDuplicateAnalyzers">
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<!-- This package should replace the "Microsoft.Extensions.Logging.Abstractions" source generator. -->
<Target Name="_Microsoft_Extensions_Logging_AbstractionsRemoveAnalyzers"
<Target Name="_Microsoft_Extensions_Telemetry_AbstractionsRemoveAnalyzers"
Condition="'$(DisableMicrosoftExtensionsLoggingSourceGenerator)' == 'true'"
AfterTargets="ResolveReferences">
<ItemGroup>
Expand All @@ -19,7 +19,7 @@
<!-- We have a WPF-specific target because WPF projects generate and compile a temporary project (via "GenerateTemporaryTargetAssembly" target),
and that temp project doesn't have "ResolveReferences" target we expect.
This leads to the runtime's generator not being removed and to a compile-time error CS0757. This additional target resolves the problem. -->
<Target Name="_Microsoft_Extensions_Logging_AbstractionsRemoveAnalyzersWPF"
<Target Name="_Microsoft_Extensions_Telemetry_AbstractionsRemoveAnalyzersWPF"
Condition="'$(DisableMicrosoftExtensionsLoggingSourceGenerator)' == 'true'"
AfterTargets="RemoveDuplicateAnalyzers">
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This package should replace the Microsoft.Extensions.Logging.Abstractions source generator, so we set the property to remove the source generator from the project. -->
<PropertyGroup>
<DisableMicrosoftExtensionsLoggingSourceGenerator>true</DisableMicrosoftExtensionsLoggingSourceGenerator>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project>
<!-- This package should replace the "Microsoft.Extensions.Logging.Abstractions" source generator. -->
<Target Name="_Microsoft_Extensions_Telemetry_AbstractionsRemoveAnalyzers"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand why this new net9 folder is needed? the way buildTransitive folder works, should make it such that if a net9 folder is not present but the app targets net9, it should just fallback and import the files from net8.

Condition="'$(DisableMicrosoftExtensionsLoggingSourceGenerator)' == 'true'"
AfterTargets="ResolveReferences">
<ItemGroup>
<_Microsoft_Extensions_Logging_AbstractionsAnalyzer
Include="@(Analyzer)"
Condition="'%(Analyzer.AssemblyName)' == 'Microsoft.Extensions.Logging.Generators' Or
'%(Analyzer.NuGetPackageId)' == 'Microsoft.Extensions.Logging.Abstractions'" />
</ItemGroup>

<!-- Remove Microsoft.Extensions.Logging.Abstractions Analyzer -->
<ItemGroup>
<Analyzer Remove="@(_Microsoft_Extensions_Logging_AbstractionsAnalyzer)" />
</ItemGroup>
</Target>

<!-- We have a WPF-specific target because WPF projects generate and compile a temporary project (via "GenerateTemporaryTargetAssembly" target),
and that temp project doesn't have "ResolveReferences" target we expect.
This leads to the runtime's generator not being removed and to a compile-time error CS0757. This additional target resolves the problem. -->
<Target Name="_Microsoft_Extensions_Telemetry_AbstractionsRemoveAnalyzersWPF"
Condition="'$(DisableMicrosoftExtensionsLoggingSourceGenerator)' == 'true'"
AfterTargets="RemoveDuplicateAnalyzers">
<ItemGroup>
<_Microsoft_Extensions_Logging_AbstractionsAnalyzerWPF
Include="@(Analyzer)"
Condition="'%(Analyzer.AssemblyName)' == 'Microsoft.Extensions.Logging.Generators' Or
'%(Analyzer.NuGetPackageId)' == 'Microsoft.Extensions.Logging.Abstractions'" />
</ItemGroup>
<!-- Remove Microsoft.Extensions.Logging.Abstractions Analyzer for WPF projects -->
<ItemGroup>
<Analyzer Remove="@(_Microsoft_Extensions_Logging_AbstractionsAnalyzerWPF)" />
</ItemGroup>
</Target>
</Project>
Loading