Sitelet https://github.com/fsprojects/Paket/pull/768/files
Skip to content
Merged
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
32 changes: 20 additions & 12 deletions src/Paket.Core/NugetConvert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ module NugetEnv =
Packages = [for node in doc.SelectNodes("//package") ->
{ Id = node.Attributes.["id"].Value
Version = node.Attributes.["version"].Value |> SemVer.Parse
TargetFramework = node |> getAttribute "targetFramework" } ]}
TargetFramework =
node |> getAttribute "targetFramework" |> Option.map (fun t -> ">= " + t) } ]}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is actually the only change necessary? i.e. we don't need to call the optimizeRestrictions function?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I think the optimization happens later anyways. :-)

|> ok
with _ -> fail (NugetPackagesConfigParseError file)

Expand Down Expand Up @@ -228,24 +229,31 @@ let createPackageRequirement (packageName, version, restrictions) sources depend
let createDependenciesFileR (rootDirectory : DirectoryInfo) nugetEnv mode =

let dependenciesFileName = Path.Combine(rootDirectory.FullName, Constants.DependenciesFileName)

let allVersions =

let allVersionsGroupped =
nugetEnv.NugetProjectFiles
|> Seq.collect (fun (_,c) -> c.Packages)
|> Seq.groupBy (fun p -> p.Id)
|> Seq.map (fun (name, packages) -> name, packages |> Seq.map (fun p -> p.Version, p.TargetFramework) |> Seq.distinct)

let findDistinctsPackages selector =
allVersionsGroupped
|> Seq.map (fun (name, packages) -> name, packages |> selector)
|> Seq.sortBy (fun (name,_) -> name.ToLower())

for (name, versions) in allVersions do
if Seq.length versions > 1
then traceWarnfn
"Package %s is referenced multiple times with different versions or target frameworks : %A. Paket will choose the latest version and disregard target framework."
name
(versions |> Seq.map string |> Seq.toList)

let findWarnings searchBy message =
for (name, versions) in
findDistinctsPackages searchBy
do
if Seq.length versions > 1
then traceWarnfn message name (versions |> Seq.toList)

findWarnings (Seq.map (fun p -> p.Version) >> Seq.distinct >> Seq.map string)
"Package %s is referenced multiple times in different versions: %A. Paket will choose the latest one."
findWarnings (Seq.map (fun p -> p.TargetFramework) >> Seq.distinct >> Seq.choose(fun target -> target) >> Seq.map string)
"Package %s is referenced multiple times with different target frameworks : %A. Paket may disregard target framework."

let latestVersions =
allVersions
findDistinctsPackages (Seq.map (fun p -> p.Version, p.TargetFramework) >> Seq.distinct)
|> Seq.map (fun (name, versions) ->
let latestVersion, _ = versions |> Seq.maxBy fst
let restrictions =
Expand Down