Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings for dependent packages should be respected #919

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 16 additions & 23 deletions src/Paket.Core/InstallProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -189,35 +189,28 @@ let InstallIntoProjects(sources, options : InstallerOptions, lockFile : LockFile
| Some p -> p
| None -> failwithf "%s uses NuGet package %O, but it was not found in the paket.lock file." referenceFile.FileName ps.Name

ps.Name,
{ ps.Settings with
FrameworkRestrictions =
// TODO: This should filter
ps.Settings.FrameworkRestrictions @
lockFile.Options.Settings.FrameworkRestrictions @
package.Settings.FrameworkRestrictions

ImportTargets =
ps.Settings.ImportTargets ++
package.Settings.ImportTargets ++
lockFile.Options.Settings.ImportTargets

CopyLocal =
ps.Settings.CopyLocal ++
package.Settings.CopyLocal ++
lockFile.Options.Settings.CopyLocal

OmitContent =
ps.Settings.OmitContent ++
package.Settings.OmitContent ++
lockFile.Options.Settings.OmitContent })
let resolvedSettings = [lockFile.Options.Settings; package.Settings;] |> List.fold (+) ps.Settings
ps.Name, resolvedSettings
)
|> Map.ofSeq


let usedPackages =
let d = ref usedPackages

for name,settings in usedPackages |> Seq.collect (fun u -> lookup.[NormalizedPackageName u.Key] |> Seq.map (fun x -> x,u.Value)) do
/// we want to thread the settings from the references file through the computation so that it can be used as the base that
/// the other settings modify. in this way we ensure that references files can override the dependencies file, which in turn overrides the lockfile.
let usedPackageDependencies =
usedPackages
|> Seq.collect (fun u -> lookup.[NormalizedPackageName u.Key] |> Seq.map (fun i -> u.Value, i))
|> Seq.choose (fun (parentSettings, dep) ->
match packages |> Map.tryFind (NormalizedPackageName dep) with
| None -> None
| Some p ->
let resolvedSettings = [lockFile.Options.Settings; p.Settings;] |> List.fold (+) parentSettings
Some (p.Name, resolvedSettings) )

for name,settings in usedPackageDependencies do
if (!d).ContainsKey name |> not then
d := Map.add name settings !d

Expand Down
9 changes: 9 additions & 0 deletions src/Paket.Core/Requirements.fs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ type InstallSettings =

override this.ToString() = this.ToString(false)

static member (+)(self, other : InstallSettings) =
{
self with
ImportTargets = self.ImportTargets ++ other.ImportTargets
FrameworkRestrictions = (self.FrameworkRestrictions @ other.FrameworkRestrictions) |> Seq.ofList |> Seq.distinct |> List.ofSeq
OmitContent = self.OmitContent ++ other.OmitContent
CopyLocal = self.CopyLocal ++ other.CopyLocal
}

static member Parse(text:string) : InstallSettings =
let kvPairs = parseKeyValuePairs text

Expand Down