This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 428
/
NETStandard.Library.targets
139 lines (125 loc) · 8.08 KB
/
NETStandard.Library.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(NETStandardToolsTaskDirectory)' == ''">
<NETStandardToolsTaskDirectory>$(MSBuildThisFileDirectory)</NETStandardToolsTaskDirectory>
<NETStandardToolsTaskDirectory Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)desktop/</NETStandardToolsTaskDirectory>
</PropertyGroup>
<PropertyGroup>
<NETStandardLibraryPackageVersion>#VERSION#</NETStandardLibraryPackageVersion>
</PropertyGroup>
<Choose>
<!-- Allow completely disabling the conflict resolution targets-->
<When Condition="'$(DisableHandlePackageFileConflicts)' == 'true'" />
<!-- Condition here is a hack until https://github.com/dotnet/sdk/issues/534 is fixed -->
<When Condition="'$(TargetFramework)' != '' or '$(TargetFrameworks)' != ''">
<!-- NuGet 4, run after the targets that construct items from deps -->
<PropertyGroup>
<HandlePackageFileConflictsAfter>ResolvePackageDependenciesForBuild</HandlePackageFileConflictsAfter>
<HandlePublishFileConflictsAfter>RunResolvePublishAssemblies</HandlePublishFileConflictsAfter>
<RemoveDepsFileConflictsAfter>GenerateBuildDependencyFile</RemoveDepsFileConflictsAfter>
<RemovePublishDepsFileConflictsAfter>GeneratePublishDependencyFile</RemovePublishDepsFileConflictsAfter>
<!-- If CopyLocalLockFileAssemblies is not true the host will run from packages,
but we still need to consider those package items for conflicts -->
<HandlePackageFileConflictsDependsOn Condition="'$(CopyLocalLockFileAssemblies)' != 'true'">_GetLockFileAssemblies</HandlePackageFileConflictsDependsOn>
</PropertyGroup>
</When>
<When Condition="'$(ResolveNuGetPackages)' == 'true' and Exists('$(ProjectLockFile)')">
<!-- NuGet 3, run after the target that constructs items from lock file -->
<PropertyGroup>
<HandlePackageFileConflictsAfter>ResolveNuGetPackageAssets</HandlePackageFileConflictsAfter>
</PropertyGroup>
</When>
<Otherwise>
<!-- NuGet 2, run before targets that consume references -->
<PropertyGroup>
<ResolveAssemblyReferencesDependsOn>$(ResolveAssemblyReferencesDependsOn);HandlePackageFileConflicts</ResolveAssemblyReferencesDependsOn>
<PrepareResourcesDependsOn>HandlePackageFileConflicts;$(PrepareResourcesDependsOn)</PrepareResourcesDependsOn>
</PropertyGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Reference Condition="'$(_NetStandardLibraryRefPath)' != ''" Include="$(_NetStandardLibraryRefPath)*.dll">
<!-- Private = false to make these reference only -->
<Private>false</Private>
<NuGetPackageId>NETStandard.Library</NuGetPackageId>
<NuGetPackageVersion>$(NETStandardLibraryPackageVersion)</NuGetPackageVersion>
<NuGetIsFrameworkReference>false</NuGetIsFrameworkReference>
<NuGetSourceType>Package</NuGetSourceType>
</Reference>
<ReferenceCopyLocalPaths Condition="'$(_NetStandardLibraryLibPath)' != ''" Include="$(_NetStandardLibraryLibPath)*.dll">
<Private>false</Private>
<NuGetPackageId>NETStandard.Library</NuGetPackageId>
<NuGetPackageVersion>$(NETStandardLibraryPackageVersion)</NuGetPackageVersion>
<NuGetIsFrameworkReference>false</NuGetIsFrameworkReference>
<NuGetSourceType>Package</NuGetSourceType>
</ReferenceCopyLocalPaths>
</ItemGroup>
<Target Name="_GetLockFileAssemblies"
DependsOnTargets="ComputePrivateAssetsPackageReferences;
_DefaultMicrosoftNETPlatformLibrary">
<!-- Essentially a copy of the SDKs RunResolvePublishAssemblies.
We need to find all the files that will be loaded from deps for conflict resolution.-->
<ResolvePublishAssemblies ProjectPath="$(MSBuildProjectFullPath)"
AssetsFilePath="$(ProjectAssetsFile)"
TargetFramework="$(TargetFrameworkMoniker)"
RuntimeIdentifier="$(RuntimeIdentifier)"
PlatformLibraryName="$(MicrosoftNETPlatformLibrary)"
PrivateAssetsPackageReferences="@(PrivateAssetsPackageReference)">
<Output TaskParameter="AssembliesToPublish" ItemName="_LockFileAssemblies" />
</ResolvePublishAssemblies>
</Target>
<UsingTask TaskName="HandlePackageFileConflicts" AssemblyFile="$(NETStandardToolsTaskDirectory)NETStandard.Tools.dll" />
<Target Name="HandlePackageFileConflicts" AfterTargets="$(HandlePackageFileConflictsAfter)" DependsOnTargets="$(HandlePackageFileConflictsDependsOn)">
<HandlePackageFileConflicts References="@(Reference)"
ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
OtherRuntimeItems="@(_LockFileAssemblies)"
PlatformManifests="@(PackageConflictPlatformManifests)"
PreferredPackages="$(PackageConflictPreferredPackages)">
<Output TaskParameter="ReferencesWithoutConflicts" ItemName="_ReferencesWithoutConflicts" />
<Output TaskParameter="ReferenceCopyLocalPathsWithoutConflicts" ItemName="_ReferenceCopyLocalPathsWithoutConflicts" />
<Output TaskParameter="Conflicts" ItemName="_ConflictPackageFiles" />
</HandlePackageFileConflicts>
<!-- Replace Reference / ReferenceCopyLocalPaths with the filtered lists.
We must remove all and include rather than just remove since removal is based
only on ItemSpec and duplicate ItemSpecs may exist with different metadata
(eg: HintPath) -->
<ItemGroup>
<Reference Remove="@(Reference)" />
<Reference Include="@(_ReferencesWithoutConflicts)" />
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" />
<ReferenceCopyLocalPaths Include="@(_ReferenceCopyLocalPathsWithoutConflicts)" />
</ItemGroup>
</Target>
<PropertyGroup>
<_RemoveDepsFileConflictsSemaphore>$(IntermediateOutputPath)\RemoveDepsFileConflicts.semaphore</_RemoveDepsFileConflictsSemaphore>
</PropertyGroup>
<UsingTask TaskName="RemoveDepsFileConflicts" AssemblyFile="$(NETStandardToolsTaskDirectory)NETStandard.Tools.dll" />
<Target Name="RemoveDepsFileConflicts" AfterTargets="$(RemoveDepsFileConflictsAfter)"
Inputs="$(ProjectDepsFilePath)" Outputs="$(_RemoveDepsFileConflictsSemaphore)">
<RemoveDepsFileConflicts DepsFilePath="$(ProjectDepsFilePath)" Conflicts="@(_ConflictPackageFiles)" />
<Touch Files="$(_RemoveDepsFileConflictsSemaphore)" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>
<Target Name="HandlePublishFileConflicts" AfterTargets="$(HandlePublishFileConflictsAfter)">
<HandlePackageFileConflicts ReferenceCopyLocalPaths="@(ResolvedAssembliesToPublish)"
PlatformManifests="@(PackageConflictPlatformManifests)"
PreferredPackages="$(PackageConflictPreferredPackages)">
<Output TaskParameter="ReferenceCopyLocalPathsWithoutConflicts" ItemName="_ResolvedAssembliesToPublishWithoutConflicts" />
<Output TaskParameter="Conflicts" ItemName="_PublishConflictPackageFiles" />
</HandlePackageFileConflicts>
<ItemGroup>
<ResolvedAssembliesToPublish Remove="@(ResolvedAssembliesToPublish)" />
<ResolvedAssembliesToPublish Include="@(_ResolvedAssembliesToPublishWithoutConflicts)" />
</ItemGroup>
</Target>
<PropertyGroup>
<_RemovePublishDepsFileConflictsSemaphore>$(IntermediateOutputPath)\RemovePublishDepsFileConflicts.semaphore</_RemovePublishDepsFileConflictsSemaphore>
</PropertyGroup>
<Target Name="RemovePublishDepsFileConflicts" AfterTargets="$(RemovePublishDepsFileConflictsAfter)"
Inputs="$(PublishDepsFilePath)" Outputs="$(_RemovePublishDepsFileConflictsSemaphore)">
<RemoveDepsFileConflicts DepsFilePath="$(PublishDepsFilePath)" Conflicts="@(_ConflictPackageFiles);@(_PublishConflictPackageFiles)" />
<Touch Files="$(_RemovePublishDepsFileConflictsSemaphore)" AlwaysCreate="true">
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>
</Project>