-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathDirectory.Build.targets
117 lines (96 loc) · 6.25 KB
/
Directory.Build.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<Project>
<Import Project="..\..\Directory.Build.targets" />
<!-- netstandard2.0's targeting pack uses the old package reference model which doesn't support using a local layout.
Therefore disable the package reference download via DisableImplicitFrameworkReferences and manually import the
packages' targets file to receive the references. -->
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<NETStandardLibraryArtifactsDir>$(ArtifactsBinDir)NETStandard.Library.2.0.3\pack\</NETStandardLibraryArtifactsDir>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>
<Import Project="$(NETStandardLibraryArtifactsDir)build\netstandard2.0\NETStandard.Library.targets" Condition="'$(TargetFramework)' == 'netstandard2.0' and '$(ExcludeRestorePackageImports)' != 'true' and Exists('$(NETStandardLibraryArtifactsDir)')" />
<PropertyGroup>
<EnableTargetingPackDownload>false</EnableTargetingPackDownload>
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
<!-- Avoid transitive framework reference downloads to minimize the number of targeting packs and prebuilts. -->
<DisableTransitiveFrameworkReferenceDownloads>true</DisableTransitiveFrameworkReferenceDownloads>
<CustomizationsPropsPath>$(MSBuildProjectDirectory)\$(CustomizationsPropsFile)</CustomizationsPropsPath>
<CustomizationsSourcePath>$(MSBuildProjectDirectory)\$(CustomizationsSourceFile)</CustomizationsSourcePath>
</PropertyGroup>
<ItemGroup>
<Compile Include="ref/$(TargetFramework)/*$(DefaultLanguageSourceExtension)" />
<Compile Include="lib/$(TargetFramework)/*$(DefaultLanguageSourceExtension)" />
<!-- Attributes for all Reference Packages -->
<Compile Include="$(RepoRoot)src\SourceBuildAssemblyMetdata.cs" />
<!-- Customization extension point -->
<Compile Include="$(CustomizationsSourcePath)" Condition="Exists('$(CustomizationsSourcePath)')" />
</ItemGroup>
<!-- Customization extension point -->
<Import Project="$(CustomizationsPropsPath)" Condition="Exists('$(CustomizationsPropsPath)')" />
<!--
### Targeting Packs section ###
Keep in sync with available targeting packs under src/targetPacks/ILsrc.
-->
<ItemGroup>
<KnownFrameworkReference Update="@(KnownFrameworkReference->WithMetadataValue('Identity', 'Microsoft.NETCore.App'))">
<TargetingPackVersion Condition="'%(TargetFramework)' == 'netcoreapp3.0'">3.0.0</TargetingPackVersion>
<TargetingPackVersion Condition="'%(TargetFramework)' == 'netcoreapp3.1'">3.1.0</TargetingPackVersion>
<TargetingPackVersion Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(TargetFramework)', '^net\d+\.0$'))">$([System.Text.RegularExpressions.Regex]::Match('%(TargetFramework)', '\d+').Value).0.0</TargetingPackVersion>
</KnownFrameworkReference>
<KnownFrameworkReference Update="@(KnownFrameworkReference->WithMetadataValue('Identity', 'NETStandard.Library'))">
<TargetingPackVersion Condition="'%(TargetFramework)' == 'netstandard2.1'">2.1.0</TargetingPackVersion>
</KnownFrameworkReference>
</ItemGroup>
<!-- Conflict resolution doesn't see P2Ps: https://github.com/dotnet/sdk/issues/2674. -->
<Target Name="PassProjectReferencesToConflictResolution"
BeforeTargets="_HandlePackageFileConflicts"
DependsOnTargets="ResolveProjectReferences">
<ItemGroup>
<Reference Include="@(_ResolvedProjectReferencePaths)" />
<_ResolvedProjectReferencePaths Remove="@(_ResolvedProjectReferencePaths)" />
</ItemGroup>
</Target>
<!-- Filter out conflicting implicit assembly references. -->
<Target Name="FilterImplicitAssemblyReferences"
DependsOnTargets="ResolveProjectReferences"
AfterTargets="ResolveTargetingPackAssets">
<ItemGroup>
<_targetingPackReferenceExclusion Include="$(TargetName)" />
</ItemGroup>
<ItemGroup>
<_targetingPackReferenceWithProjectName Include="@(Reference->WithMetadataValue('ExternallyResolved', 'true')->Metadata('Filename'))"
OriginalIdentity="%(Identity)" />
<_targetingPackIncludedReferenceWithProjectName Include="@(_targetingPackReferenceWithProjectName)"
Exclude="@(_targetingPackReferenceExclusion)" />
<_targetingPackExcludedReferenceWithProjectName Include="@(_targetingPackReferenceWithProjectName)"
Exclude="@(_targetingPackIncludedReferenceWithProjectName)" />
<Reference Remove="@(_targetingPackExcludedReferenceWithProjectName->Metadata('OriginalIdentity'))" />
</ItemGroup>
</Target>
<Target Name="CopyBuildOutputToTempOutput"
AfterTargets="CopyFilesToOutputDirectory">
<ItemGroup>
<CompileWithRelativePath Include="@(Compile)" Condition="!$([System.String]::new('%(Identity)').StartsWith('%(RootDir)'))" />
</ItemGroup>
<Error
Condition="@(CompileWithRelativePath->Count()) != 1"
Text="Number of Compile items != 1. We need just one, to determine the path of the resulting DLL in the package including ref/lib and TFM." />
<ItemGroup>
<FullCompileDir Include="$([System.IO.Directory]::GetParent('%(CompileWithRelativePath.Identity)'))" />
<RelativeCompileDir Include="$([MSBuild]::MakeRelative('$(MSBuildProjectDirectory)\', '%(FullCompileDir.Identity)'))" />
</ItemGroup>
<Copy
SourceFiles="$(TargetPath)"
DestinationFiles="$([MSBuild]::NormalizePath(
'$(TFMPackTempOutputDir)',
'%(RelativeCompileDir.Identity)',
'$(TargetFileName)'))" />
</Target>
<!-- Use local targeting packs -->
<Target Name="UseLocalTargetingPack" AfterTargets="ResolveFrameworkReferences">
<ItemGroup>
<ResolvedTargetingPack Path="$(ArtifactsBinDir)%(ResolvedTargetingPack.NuGetPackageId).%(ResolvedTargetingPack.NuGetPackageVersion)\pack"
PackageDirectory="$(ArtifactsBinDir)%(ResolvedTargetingPack.NuGetPackageId).%(ResolvedTargetingPack.NuGetPackageVersion)\pack" />
<ResolvedFrameworkReference TargetingPackPath="$(ArtifactsBinDir)%(ResolvedFrameworkReference.TargetingPackName).%(ResolvedFrameworkReference.TargetingPackVersion)\pack" />
</ItemGroup>
</Target>
</Project>