Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViktor Hofer <viktor.hofer@microsoft.com>2022-05-12 10:22:26 +0300
committerGitHub <noreply@github.com>2022-05-12 10:22:26 +0300
commitd3af4921f36dba8dde35ade7dff59a3a192edddb (patch)
treecdaf3acef9a30cdb90fada81bed2ede820e4fc0c /eng/generators.targets
parent35e47797a36e29475d28af61f0fa0fb3bf067838 (diff)
Define convention to consume and/or package analyzers (#69069)
* Define convention to include analyzers in ref pack Fixes https://github.com/dotnet/runtime/issues/61321 Until now we required source libraries to define ProjectReferences when an analyzer should be part of the shared framework. That strategy causes analyzer projects to leak into the ProjectReference closure and by that into a solution file. As an example: When another library references the source library that references the analyzer, the analyzer is part of the dependency closure even though it might not be required. This change makes it possible to define the shared framework analyzer projects in the NetCoreAppLibrary.props file for both the .NETCoreApp, and the AspNetCoreApp shared framework. Out-of-band projects which ship analyzers inside their produced package, continue to reference the analyzers via the `AnalyzerProject` item. * Use AnalyzerReference consistently * Don't reference analyzer when its packaged * Fix P2P reference * Fix multi target roslyn component target condition
Diffstat (limited to 'eng/generators.targets')
-rw-r--r--eng/generators.targets17
1 files changed, 9 insertions, 8 deletions
diff --git a/eng/generators.targets b/eng/generators.targets
index 69c3c12cbb4..c123ad66387 100644
--- a/eng/generators.targets
+++ b/eng/generators.targets
@@ -41,17 +41,18 @@
That is required as the EnabledGenerators condition checks on the Reference and ProjectReference items and hence can't be a property condition. -->
<ItemGroup Condition="'@(EnabledGenerators)' != '' and
@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'LibraryImportGenerator'))">
- <ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj;
- $(LibrariesProjectRoot)System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj"
- OutputItemType="Analyzer"
- ReferenceOutputAssembly="false" />
+ <AnalyzerReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj;
+ $(LibrariesProjectRoot)System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj" />
</ItemGroup>
- <!-- Use a normal property condition as this source generator is opt-in and doesn't read from an item list. -->
- <ItemGroup Condition="'$(EnableRegexGenerator)' == 'true'">
- <ProjectReference Include="$(LibrariesProjectRoot)System.Text.RegularExpressions\gen\System.Text.RegularExpressions.Generator.csproj"
+ <!-- AnalyzerReference items are transformed to ProjectReferences with the required analyzer metadata. -->
+ <ItemGroup>
+ <ProjectReference Include="@(AnalyzerReference)"
+ ReferenceOutputAssembly="false"
OutputItemType="Analyzer"
- ReferenceOutputAssembly="false" />
+ Pack="false" />
+ <ProjectReference Update="@(AnalyzerReference->WithMetadataValue('ReferenceAnalyzer', 'false'))"
+ OutputItemType="" />
</ItemGroup>
<Target Name="ConfigureGenerators"