-
Notifications
You must be signed in to change notification settings - Fork 378
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
87 lines (69 loc) · 3.38 KB
/
Directory.Build.targets
File metadata and controls
87 lines (69 loc) · 3.38 KB
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
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
==============================================================
Central Package Management Metadata Propagation
CPM does not propagate metadata such as PrivateAssets from
PackageVersion to PackageReference. This bridges that gap
so the intent can be declared centrally in Directory.Packages.props.
This must operate at evaluation time (not inside a Target) for
NuGet restore to observe the metadata. MSBuild evaluation does
not support dynamic metadata inspection, so each known NuGet
metadata type is handled explicitly.
==============================================================
-->
<ItemGroup>
<_CpmPrivateAssets Include="@(PackageVersion->HasMetadata('PrivateAssets'))" />
<_CpmIncludeAssets Include="@(PackageVersion->HasMetadata('IncludeAssets'))" />
<_CpmExcludeAssets Include="@(PackageVersion->HasMetadata('ExcludeAssets'))" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="@(_CpmPrivateAssets)" PrivateAssets="%(_CpmPrivateAssets.PrivateAssets)" />
<PackageReference Update="@(_CpmIncludeAssets)" IncludeAssets="%(_CpmIncludeAssets.IncludeAssets)" />
<PackageReference Update="@(_CpmExcludeAssets)" ExcludeAssets="%(_CpmExcludeAssets.ExcludeAssets)" />
</ItemGroup>
<!--
==============================================================
GenAPI Target: Generate public API surface
==============================================================
-->
<!-- GenAPI Properties -->
<PropertyGroup>
<GenAPIOutputDirectory>$(RepositoryRoot)api\</GenAPIOutputDirectory>
</PropertyGroup>
<!-- Import GenAPI Task package when exporting API -->
<ItemGroup Condition="'$(ExportingApi)' == 'true'">
<PackageReference Include="Microsoft.DotNet.GenAPI.Task" PrivateAssets="All" />
</ItemGroup>
<!--
ExportApi target: Generates the public API surface for the OpenAI library.
Usage:
dotnet build src/OpenAI.csproj -t:ExportApi -c Release -p:ExportingApi=true
Outputs to:
api/OpenAI.<TargetFramework>.cs
-->
<!-- Outer build target: Dispatches to inner builds for each target framework -->
<Target Name="ExportApi"
Condition="'$(MSBuildProjectName)' == 'OpenAI' and '$(TargetFramework)' == '' and '$(TargetFrameworks)' != ''">
<ItemGroup>
<_ExportApiTargetFramework Include="$(TargetFrameworks)" />
</ItemGroup>
<ItemGroup>
<_ExportApiProject Include="$(MSBuildProjectFile)"
AdditionalProperties="TargetFramework=%(_ExportApiTargetFramework.Identity);ExportingApi=true" />
</ItemGroup>
<MSBuild Projects="@(_ExportApiProject)"
Targets="ExportApiInner"
BuildInParallel="true" />
</Target>
<!-- Inner build target: Runs for each specific target framework -->
<Target Name="ExportApiInner"
DependsOnTargets="Build"
Condition="'$(MSBuildProjectName)' == 'OpenAI' and '$(TargetFramework)' != ''">
<!-- Run GenAPI task -->
<GenAPITask Assemblies="$(TargetPath)"
AssemblyReferences="@(ReferencePath)"
OutputPath="$(GenAPIOutputDirectory)OpenAI.$(TargetFramework).cs" />
<Message Importance="high"
Text="Generated API surface: $(GenAPIOutputDirectory)OpenAI.$(TargetFramework).cs" />
</Target>
</Project>