-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathgenerators.targets
91 lines (83 loc) · 5.91 KB
/
generators.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<Project>
<ItemGroup>
<EnabledGenerators Include="LibraryImportGenerator" Condition="'$(EnableLibraryImportGenerator)' == 'true'" />
<!-- We enable the Downlevel LibraryImportGenerator
when the project is a C# source or test project that:
- doesn't target the a TFM that includes LibraryImportGenerator -->
<EnabledGenerators Include="DownlevelLibraryImportGenerator"
Condition="'$(EnableLibraryImportGenerator)' == '' and
(
'$(IsSourceProject)' == 'true' or
'$(IsTestProject)' == 'true' or
'$(IsTestSupportProject)' == 'true'
) and
'$(MSBuildProjectExtension)' == '.csproj' and
'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
<!-- We enable the LibraryImportGenerator source generator
when the project is a C# source project that:
- references System.Private.CoreLib directly
- references System.Runtime.InteropServices directly and not through the live targeting pack (i.e. when inbox) -->
<EnabledGenerators Include="LibraryImportGenerator"
Condition="'$(EnableLibraryImportGenerator)' == '' and
'$(IsSourceProject)' == 'true' and
'$(MSBuildProjectExtension)' == '.csproj' and
(
'$(DisableImplicitFrameworkReferences)' == 'true' and
(
'@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices'))' == 'true' or
'@(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))' == 'true'
)
)" />
<!-- We enable the ComInterfaceGenerator source generator
when the project is a C# source project that:
- references System.Runtime.InteropServices directly and not through the live targeting pack (i.e. when inbox) -->
<EnabledGenerators Include="ComInterfaceGenerator"
Condition="'$(IsSourceProject)' == 'true' and
'$(MSBuildProjectExtension)' == '.csproj' and
(
'$(DisableImplicitFrameworkReferences)' == 'true' and
'@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices'))' == 'true'
)" />
</ItemGroup>
<ItemGroup Condition="'@(EnabledGenerators)' != '' and
@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'DownlevelLibraryImportGenerator'))">
<Compile Include="$(CoreLibSharedDir)System\Runtime\InteropServices\LibraryImportAttribute.cs" />
<Compile Include="$(CoreLibSharedDir)System\Runtime\InteropServices\StringMarshalling.cs" />
</ItemGroup>
<!-- Use this complex item list based filtering to add the ProjectReference to make sure dotnet/runtime stays compatible with NuGet Static Graph Restore.
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)' != ''">
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"
SetConfiguration="Configuration=$(LibrariesConfiguration)" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\DownlevelLibraryImportGenerator\DownlevelLibraryImportGenerator.csproj"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"
SetConfiguration="Configuration=$(LibrariesConfiguration)"
Condition="@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'DownlevelLibraryImportGenerator'))" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"
SetConfiguration="Configuration=$(LibrariesConfiguration)"
Condition="@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'LibraryImportGenerator'))" />
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\ComInterfaceGenerator\ComInterfaceGenerator.csproj"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer"
SetConfiguration="Configuration=$(LibrariesConfiguration)"
Condition="@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'ComInterfaceGenerator'))" />
</ItemGroup>
<Target Name="ConfigureGenerators"
DependsOnTargets="ConfigureLibraryImportGenerator"
BeforeTargets="CoreCompile" />
<!-- Microsoft.Interop.LibraryImportGenerator -->
<Target Name="ConfigureLibraryImportGenerator"
Condition="'@(EnabledGenerators)' != '' and @(EnabledGenerators->AnyHaveMetadataValue('Identity', 'LibraryImportGenerator'))"
DependsOnTargets="ResolveProjectReferences"
BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun">
<PropertyGroup>
<LibraryImportGenerator_UseMarshalType>true</LibraryImportGenerator_UseMarshalType>
</PropertyGroup>
</Target>
<Import Project="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\LibraryImportGenerator\Microsoft.Interop.LibraryImportGenerator.props" />
</Project>