-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathDirectory.Build.targets
More file actions
60 lines (52 loc) · 3.07 KB
/
Directory.Build.targets
File metadata and controls
60 lines (52 loc) · 3.07 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
<Project>
<!-- Enables "ExactVersion" attribute on "ProjectReference" to allow an exact NuGet reference version to be used.
https://github.com/NuGet/Home/issues/5556#issuecomment-1179526189 -->
<Target Name="UseExplicitPackageVersions" BeforeTargets="GenerateNuspec">
<ItemGroup>
<_ProjectReferenceWithExplicitPackageVersion Include="@(ProjectReference->'%(FullPath)')" Condition="'%(ProjectReference.PackageVersion)' != ''" />
<_ProjectReferenceWithExactPackageVersion Include="@(ProjectReference->'%(FullPath)')" Condition="'%(ProjectReference.ExactVersion)' == 'true'" />
<_ProjectReferenceWithReassignedVersion Include="@(_ProjectReferencesWithVersions)" Condition="'%(Identity)' != '' And '@(_ProjectReferenceWithExplicitPackageVersion)' == '@(_ProjectReferencesWithVersions)'">
<ProjectVersion>@(_ProjectReferenceWithExplicitPackageVersion->'%(PackageVersion)')</ProjectVersion>
</_ProjectReferenceWithReassignedVersion>
<_ProjectReferenceWithReassignedVersion Include="@(_ProjectReferencesWithVersions)" Condition="'%(Identity)' != '' And '@(_ProjectReferenceWithExactPackageVersion)' == '@(_ProjectReferencesWithVersions)'">
<ProjectVersion>[@(_ProjectReferencesWithVersions->'%(ProjectVersion)')]</ProjectVersion>
</_ProjectReferenceWithReassignedVersion>
<_ProjectReferencesWithVersions Remove="@(_ProjectReferenceWithReassignedVersion)" />
<_ProjectReferencesWithVersions Include="@(_ProjectReferenceWithReassignedVersion)" />
</ItemGroup>
</Target>
<PropertyGroup>
<!-- Mark .NET6+ packages as supporting trimming -->
<IsTrimmable Condition=" $([MSBuild]::VersionGreaterThanOrEquals('$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)'))', '6.0')) ">true</IsTrimmable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.ApiTools.MSBuildTasks" Version="0.4.0" PrivateAssets="all" />
</ItemGroup>
<Target Name="_GeneratePublicApiFiles"
AfterTargets="Build"
Condition="'$(TargetFramework)' != '' and '$(PublicAPIShippedFile)' != '' and '$(PublicAPIUnshippedFile)' != ''"
Inputs="$(TargetDir)$(AssemblyName).dll"
Outputs="$(IntermediateOutputPath)GeneratePublicApiFiles.stamp">
<!-- Make sure the empty files exist -->
<WriteLinesToFile
Condition="!Exists('$(PublicAPIShippedFile)')"
File="$(PublicAPIShippedFile)"
Lines="#nullable enable" />
<WriteLinesToFile
Condition="!Exists('$(PublicAPIUnshippedFile)')"
File="$(PublicAPIUnshippedFile)"
Lines="#nullable enable" />
<!-- Generate the public API files -->
<GeneratePublicApiFiles
Assembly="$(TargetDir)$(AssemblyName).dll"
Files="@(PublicAPIFiles)"
ReferenceSearchPaths="@(ReferencePath)" />
<!-- Touch the stamp file to indicate that the public API files have been generated -->
<Touch
Files="$(IntermediateOutputPath)GeneratePublicApiFiles.stamp"
AlwaysCreate="True" />
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)GeneratePublicApiFiles.stamp" />
</ItemGroup>
</Target>
</Project>