diff --git a/src/Paket.Core/Installation/RestoreProcess.fs b/src/Paket.Core/Installation/RestoreProcess.fs index a86a1cbc4b..5817925a6f 100644 --- a/src/Paket.Core/Installation/RestoreProcess.fs +++ b/src/Paket.Core/Installation/RestoreProcess.fs @@ -176,8 +176,9 @@ let CreateInstallModel(alternativeProjectRoot, root, groupName, sources, caches, let! (package, content) = ExtractPackage(alternativeProjectRoot, root, groupName, sources, caches, force, package, false) let model = InstallModel.CreateFromContent( - package.Name, package.Version, - package.Settings.FrameworkRestrictions |> Requirements.getExplicitRestriction, + package.Name, + package.Version, + Requirements.getExplicitRestriction package.Settings.FrameworkRestrictions, content.Force()) return (groupName,package.Name), (package,model) } diff --git a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs index 78e3c04d18..4b8edf0a3a 100644 --- a/src/Paket.Core/PaketConfigFiles/ProjectFile.fs +++ b/src/Paket.Core/PaketConfigFiles/ProjectFile.fs @@ -785,8 +785,16 @@ module ProjectFile = | "$(TargetFrameworkIdentifier) == 'true'" -> "true" | _ -> condition - let frameworkReferences = libFolder.FolderContents.FrameworkReferences |> Seq.sortBy (fun (r) -> r.Name) |> Seq.toList - let libraries = libFolder.FolderContents.Libraries |> Seq.sortBy (fun (r) -> r.Path) |> Seq.toList + let frameworkReferences = + libFolder.FolderContents.FrameworkReferences + |> Seq.sortBy (fun r -> r.Name) + |> Seq.toList + + let libraries = + libFolder.FolderContents.Libraries + |> Seq.sortBy (fun r -> r.Path) + |> Seq.toList + let assemblyTargets = ref libFolder.Targets let duplicates = HashSet<_>() for frameworkAssembly in frameworkReferences do @@ -799,7 +807,8 @@ module ProjectFile = [condition,createItemGroup libFolder.Targets frameworkReferences libraries,false] else let specialFrameworkAssemblies, rest = - frameworkReferences |> List.partition (fun fr -> duplicates.Contains fr.Name) + frameworkReferences + |> List.partition (fun fr -> duplicates.Contains fr.Name) match PlatformMatching.getCondition referenceCondition allTargets !assemblyTargets with | "" -> [condition,createItemGroup libFolder.Targets rest libraries,false] @@ -1095,22 +1104,41 @@ module ProjectFile = let usedFrameworkLibs = HashSet() - completeModel - |> Seq.filter (fun kv -> usedPackages.ContainsKey kv.Key) - |> Seq.sortBy (fun kv -> let group, packName = kv.Key in group.CompareString, packName.CompareString) - |> Seq.map (fun kv -> - deleteCustomModelNodes (snd kv.Value) project - let installSettings = snd usedPackages.[kv.Key] - let restrictionList = - installSettings.FrameworkRestrictions - |> getExplicitRestriction - - let projectModel = - (snd kv.Value) - .ApplyFrameworkRestrictions(restrictionList) - .FilterExcludes(installSettings.Excludes) - .RemoveIfCompletelyEmpty() + let specialPackagesWithFrameworkConflictLibs = + [PackageName "System.Net.Http"] // see https://github.com/fsprojects/Paket/issues/2352 + |> Set.ofList + let filteredModel = + completeModel + |> Map.filter (fun kv _ -> usedPackages.ContainsKey kv) + + filteredModel + |> Seq.map (fun kv -> + deleteCustomModelNodes (snd kv.Value) project + let installSettings = snd usedPackages.[kv.Key] + let restrictionList = + installSettings.FrameworkRestrictions + |> getExplicitRestriction + + let projectModel = + (snd kv.Value) + .ApplyFrameworkRestrictions(restrictionList) + .FilterExcludes(installSettings.Excludes) + .RemoveIfCompletelyEmpty() + + let _, packageName = kv.Key + if specialPackagesWithFrameworkConflictLibs.Contains packageName then + for t in KnownTargetProfiles.AllProfiles do + if (projectModel.GetLibReferenceFiles t) + |> Seq.exists (fun t -> t.Name = packageName.ToString() + ".dll") + then + usedFrameworkLibs.Add(t,packageName.ToString()) |> ignore + + kv,installSettings,restrictionList,projectModel) + |> Seq.sortBy (fun (kv,_,_,_) -> + let group, packName = kv.Key + group.CompareString, packName.CompareString) + |> Seq.map (fun (kv,installSettings,restrictionList,projectModel) -> if directPackages.ContainsKey kv.Key then let targetProfile = getTargetProfile project if isTargetMatchingRestrictions(restrictionList,targetProfile) then diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index 98042c8bfa..ccd91c4225 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -32,7 +32,7 @@ paket.exe Project update - C:\temp\Library2 + C:\temp\fixed true