public override bool Execute() { var log = new MSBuildLog(Log); var forcedPackageRanks = new PackageRank(ForcedPackages); var preferredPackageRanks = new PackageRank(PreferredPackages); // resolve conflicts at compile time var referenceItems = GetConflictTaskItems(References, ConflictItemType.Reference).ToArray(); var compileConflictScope = new ConflictResolver(forcedPackageRanks, preferredPackageRanks, log); compileConflictScope.ResolveConflicts(referenceItems, ci => ItemUtilities.GetReferenceFileName(ci.OriginalItem), HandleCompileConflict); // resolve conflicts that class in output var runtimeConflictScope = new ConflictResolver(forcedPackageRanks, preferredPackageRanks, log); runtimeConflictScope.ResolveConflicts(referenceItems, ci => ItemUtilities.GetReferenceTargetPath(ci.OriginalItem), HandleRuntimeConflict); var copyLocalItems = GetConflictTaskItems(ReferenceCopyLocalPaths, ConflictItemType.CopyLocal).ToArray(); runtimeConflictScope.ResolveConflicts(copyLocalItems, ci => ItemUtilities.GetTargetPath(ci.OriginalItem), HandleRuntimeConflict); var otherRuntimeItems = GetConflictTaskItems(OtherRuntimeItems, ConflictItemType.Runtime).ToArray(); runtimeConflictScope.ResolveConflicts(otherRuntimeItems, ci => ItemUtilities.GetTargetPath(ci.OriginalItem), HandleRuntimeConflict); // resolve conflicts with platform (eg: shared framework) items // we only commit the platform items since its not a conflict if other items share the same filename. var platformConflictScope = new ConflictResolver(forcedPackageRanks, preferredPackageRanks, log); var platformItems = PlatformManifests?.SelectMany(pm => PlatformManifestReader.LoadConflictItems(pm.ItemSpec, log)) ?? Enumerable.Empty <ConflictItem>(); platformConflictScope.ResolveConflicts(platformItems, pi => pi.FileName, pi => { }); platformConflictScope.ResolveConflicts(referenceItems.Where(ri => !referenceConflicts.Contains(ri.OriginalItem)), ri => ItemUtilities.GetReferenceTargetFileName(ri.OriginalItem), HandleRuntimeConflict, commitWinner: false); platformConflictScope.ResolveConflicts(copyLocalItems.Where(ci => !copyLocalConflicts.Contains(ci.OriginalItem)), ri => ri.FileName, HandleRuntimeConflict, commitWinner: false); platformConflictScope.ResolveConflicts(otherRuntimeItems, ri => ri.FileName, HandleRuntimeConflict, commitWinner: false); ReferencesWithoutConflicts = RemoveConflicts(References, referenceConflicts); ReferenceCopyLocalPathsWithoutConflicts = RemoveConflicts(ReferenceCopyLocalPaths, copyLocalConflicts); Conflicts = CreateConflictTaskItems(allConflicts); return(!Log.HasLoggedErrors); }
public ConflictResolver(PackageRank forcedPackageRank, PackageRank preferredPackageRank, ILog log) { this.log = log; this.forcedPackageRank = forcedPackageRank; this.preferredPackageRank = preferredPackageRank; }
public ConflictResolver(PackageRank packageRank, ILog log) { this.log = log; this.packageRank = packageRank; }