-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathMicrosoft.NET.ConflictResolution.targets
118 lines (99 loc) · 5.78 KB
/
Microsoft.NET.ConflictResolution.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
<!--
***********************************************************************************************
Microsoft.NET.ConflictResolution.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Microsoft.NET.DefaultPackageConflictOverrides.targets" />
<UsingTask TaskName="ResolvePackageFileConflicts" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<UsingTask TaskName="CheckForDuplicateItemMetadata" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />
<!--
_HandlePackageFileConflicts
Handles package file conflict resolution for build.
This will differ from the conflict resolution at publish time if the publish assets differ from build.
-->
<Target Name="_HandlePackageFileConflicts" DependsOnTargets="GetFrameworkPaths;GetReferenceAssemblyPaths;ResolveTargetingPackAssets">
<ItemGroup>
<!--
All runtime assets for conflict resolution.
Exclude the copy-local items since those are passed in separately.
-->
<_RuntimeAssetsForConflictResolution
Include="@(RuntimeCopyLocalItems);
@(NativeCopyLocalItems);
@(ResourceCopyLocalItems);
@(RuntimeTargetsCopyLocalItems)"
Exclude="@(ReferenceCopyLocalPaths)" />
</ItemGroup>
<ResolvePackageFileConflicts References="@(Reference)"
Analyzers="@(Analyzer)"
ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
OtherRuntimeItems="@(_RuntimeAssetsForConflictResolution)"
PlatformManifests="@(PackageConflictPlatformManifests)"
TargetFrameworkDirectories="$(TargetFrameworkDirectory)"
PackageOverrides="@(PackageConflictOverrides)"
PreferredPackages="$(PackageConflictPreferredPackages)">
<Output TaskParameter="ReferencesWithoutConflicts" ItemName="_ReferencesWithoutConflicts" />
<Output TaskParameter="AnalyzersWithoutConflicts" ItemName="_AnalyzersWithoutConflicts" />
<Output TaskParameter="ReferenceCopyLocalPathsWithoutConflicts" ItemName="_ReferenceCopyLocalPathsWithoutConflicts" />
<Output TaskParameter="Conflicts" ItemName="_ConflictPackageFiles" />
</ResolvePackageFileConflicts>
<!-- 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)" />
<Analyzer Remove="@(Analyzer)" />
<Analyzer Include="@(_AnalyzersWithoutConflicts)" />
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" />
<ReferenceCopyLocalPaths Include="@(_ReferenceCopyLocalPathsWithoutConflicts)" />
</ItemGroup>
</Target>
<!--
_HandlePackageFileConflictsForPublish
Handles package file conflict resolution for publish.
Currently, publish assets may differ due to the following reasons:
* A package was marked as excluded from publishing (including PrivateAssets="all").
* There are runtime store packages to publish against.
* If we're preserving store layout, which alters the destination paths of files.
When none of these things are true, then we can rely on the conflict resolution from build.
-->
<Target Name="_HandlePackageFileConflictsForPublish"
AfterTargets="_ResolveCopyLocalAssetsForPublish;
_FilterSatelliteResourcesForPublish">
<ResolvePackageFileConflicts ReferenceCopyLocalPaths="@(_ResolvedCopyLocalPublishAssets)"
PlatformManifests="@(PackageConflictPlatformManifests)"
TargetFrameworkDirectories="$(TargetFrameworkDirectory)"
PreferredPackages="$(PackageConflictPreferredPackages)">
<Output TaskParameter="ReferenceCopyLocalPathsWithoutConflicts" ItemName="_ResolvedCopyLocalPublishAssetsWithoutConflicts" />
<Output TaskParameter="Conflicts" ItemName="_PublishConflictPackageFiles" />
</ResolvePackageFileConflicts>
<ItemGroup>
<_ResolvedCopyLocalPublishAssets Remove="@(_ResolvedCopyLocalPublishAssets)" />
<_ResolvedCopyLocalPublishAssets Include="@(_ResolvedCopyLocalPublishAssetsWithoutConflicts)" />
</ItemGroup>
</Target>
<!--
_HandleFileConflictsForPublish
Ensures there are no duplicate files being written to the publish output.
-->
<Target Name="_HandleFileConflictsForPublish"
AfterTargets="ComputeFilesToPublish"
Condition="'$(ErrorOnDuplicatePublishOutputFiles)' != 'false'">
<CheckForDuplicateItemMetadata
Items="@(ResolvedFileToPublish->Distinct())"
MetadataName="RelativePath">
<Output TaskParameter="DuplicatesExist" PropertyName="_ResolvedFileToPublishContainsDuplicates" />
<Output TaskParameter="DuplicateItems" ItemName="_ResolvedFileToPublishDuplicatedItems" />
</CheckForDuplicateItemMetadata>
<NETSdkError Condition="'$(_ResolvedFileToPublishContainsDuplicates)' == 'true'"
ResourceName="DuplicatePublishOutputFiles"
FormatArguments="@(_ResolvedFileToPublishDuplicatedItems, ', ')" />
</Target>
</Project>