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

generators.targets « eng - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f830dbd52f2062ca1b2b75c1c5f6e514dfefc30c (plain)
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
<Project>

  <PropertyGroup>
    <EnableLibraryImportGenerator Condition="'$(EnableLibraryImportGenerator)' == ''
                        and '$(MSBuildProjectName)' == 'System.Private.CoreLib'">true</EnableLibraryImportGenerator>
    <IncludeLibraryImportGeneratorSources Condition="'$(IncludeLibraryImportGeneratorSources)' == ''">true</IncludeLibraryImportGeneratorSources>
  </PropertyGroup>
  <ItemGroup>
    <EnabledGenerators Include="LibraryImportGenerator" Condition="'$(EnableLibraryImportGenerator)' == 'true'" />
    <!-- If the current project is not System.Private.CoreLib, we enable the LibraryImportGenerator source generator
         when the project is a C# source project that either:
         - references System.Private.CoreLib, or
         - references System.Runtime.InteropServices -->
    <EnabledGenerators Include="LibraryImportGenerator"
                       Condition="'$(EnableLibraryImportGenerator)' == ''
                        and '$(IsSourceProject)' == 'true'
                        and '$(MSBuildProjectExtension)' == '.csproj'
                        and (
                          ('@(Reference)' != ''
                            and @(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices')))
                          or ('@(ProjectReference)' != ''
                            and @(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)')))
                          or ('$(NetCoreAppCurrentTargetFrameworkMoniker)' == '$(TargetFrameworkMoniker)'
                            and '$(DisableImplicitAssemblyReferences)' == 'false'))" />
    <EnabledGenerators Include="LibraryImportGenerator"
                       Condition="'$(EnableLibraryImportGenerator)' == ''
                        and '$(IsSourceProject)' == 'true'
                        and '$(MSBuildProjectExtension)' == '.csproj'
                        and ('$(TargetFrameworkIdentifier)' == '.NETStandard' or '$(TargetFrameworkIdentifier)' == '.NETFramework' or ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '$(NetCoreAppCurrentVersion)'))))" />
  </ItemGroup>

  <!-- Use this complex ItemGroup-based filtering to add the ProjectReference to make sure dotnet/runtime stays compatible with NuGet Static Graph Restore. -->
  <ItemGroup Condition="'@(EnabledGenerators)' != ''
                        and @(EnabledGenerators->AnyHaveMetadataValue('Identity', 'LibraryImportGenerator'))">
    <ProjectReference
      Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj"
      OutputItemType="Analyzer"
      ReferenceOutputAssembly="false" />
    <ProjectReference
      Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj"
      OutputItemType="Analyzer"
      ReferenceOutputAssembly="false" />
  </ItemGroup>
  <ItemGroup Condition="'@(EnabledGenerators)' != ''
                        and @(EnabledGenerators->AnyHaveMetadataValue('Identity', 'LibraryImportGenerator'))
                        and '$(IncludeLibraryImportGeneratorSources)' == 'true'">

    <!-- Only add the following files if we are not on the latest TFM. -->
    <Compile Condition="'$(NetCoreAppCurrentTargetFrameworkMoniker)' != '$(TargetFrameworkMoniker)'"
             Include="$(CoreLibSharedDir)System\Runtime\InteropServices\LibraryImportAttribute.cs" />
    <Compile Condition="'$(NetCoreAppCurrentTargetFrameworkMoniker)' != '$(TargetFrameworkMoniker)'"
             Include="$(CoreLibSharedDir)System\Runtime\InteropServices\StringMarshalling.cs" />
  </ItemGroup>

  <ItemGroup>
    <EnabledGenerators Include="RegexGenerator" Condition="'$(EnableRegexGenerator)' == 'true'" />
  </ItemGroup>

  <!-- Use this complex ItemGroup-based filtering to add the ProjectReference to make sure dotnet/runtime stays compatible with NuGet Static Graph Restore. -->
  <ItemGroup Condition="'@(EnabledGenerators)' != ''
                        and @(EnabledGenerators->AnyHaveMetadataValue('Identity', 'RegexGenerator'))">
    <ProjectReference
      Include="$(LibrariesProjectRoot)System.Text.RegularExpressions/gen/System.Text.RegularExpressions.Generator.csproj"
      OutputItemType="Analyzer"
      ReferenceOutputAssembly="false" />
  </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>