Skip to content

Commit 8612713

Browse files
committed
Merge pull request #919 from baronfel/thread_through_settings_on_dependencies
settings for dependent packages should be respected
2 parents 5dfe838 + ac8e101 commit 8612713

2 files changed

Lines changed: 25 additions & 23 deletions

File tree

‎src/Paket.Core/InstallProcess.fs‎

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -189,35 +189,28 @@ let InstallIntoProjects(sources, options : InstallerOptions, lockFile : LockFile
189189
| Some p -> p
190190
| None -> failwithf "%s uses NuGet package %O, but it was not found in the paket.lock file." referenceFile.FileName ps.Name
191191

192-
ps.Name,
193-
{ ps.Settings with
194-
FrameworkRestrictions =
195-
// TODO: This should filter
196-
ps.Settings.FrameworkRestrictions @
197-
lockFile.Options.Settings.FrameworkRestrictions @
198-
package.Settings.FrameworkRestrictions
199-
200-
ImportTargets =
201-
ps.Settings.ImportTargets ++
202-
package.Settings.ImportTargets ++
203-
lockFile.Options.Settings.ImportTargets
204-
205-
CopyLocal =
206-
ps.Settings.CopyLocal ++
207-
package.Settings.CopyLocal ++
208-
lockFile.Options.Settings.CopyLocal
209-
210-
OmitContent =
211-
ps.Settings.OmitContent ++
212-
package.Settings.OmitContent ++
213-
lockFile.Options.Settings.OmitContent })
192+
let resolvedSettings = [lockFile.Options.Settings; package.Settings;] |> List.fold (+) ps.Settings
193+
ps.Name, resolvedSettings
194+
)
214195
|> Map.ofSeq
215196

216197

217198
let usedPackages =
218199
let d = ref usedPackages
219200

220-
for name,settings in usedPackages |> Seq.collect (fun u -> lookup.[NormalizedPackageName u.Key] |> Seq.map (fun x -> x,u.Value)) do
201+
/// we want to thread the settings from the references file through the computation so that it can be used as the base that
202+
/// the other settings modify. in this way we ensure that references files can override the dependencies file, which in turn overrides the lockfile.
203+
let usedPackageDependencies =
204+
usedPackages
205+
|> Seq.collect (fun u -> lookup.[NormalizedPackageName u.Key] |> Seq.map (fun i -> u.Value, i))
206+
|> Seq.choose (fun (parentSettings, dep) ->
207+
match packages |> Map.tryFind (NormalizedPackageName dep) with
208+
| None -> None
209+
| Some p ->
210+
let resolvedSettings = [lockFile.Options.Settings; p.Settings;] |> List.fold (+) parentSettings
211+
Some (p.Name, resolvedSettings) )
212+
213+
for name,settings in usedPackageDependencies do
221214
if (!d).ContainsKey name |> not then
222215
d := Map.add name settings !d
223216

‎src/Paket.Core/Requirements.fs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ type InstallSettings =
155155

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

158+
static member (+)(self, other : InstallSettings) =
159+
{
160+
self with
161+
ImportTargets = self.ImportTargets ++ other.ImportTargets
162+
FrameworkRestrictions = (self.FrameworkRestrictions @ other.FrameworkRestrictions) |> Seq.ofList |> Seq.distinct |> List.ofSeq
163+
OmitContent = self.OmitContent ++ other.OmitContent
164+
CopyLocal = self.CopyLocal ++ other.CopyLocal
165+
}
166+
158167
static member Parse(text:string) : InstallSettings =
159168
let kvPairs = parseKeyValuePairs text
160169

0 commit comments

Comments
 (0)