Skip to content

Commit

Permalink
Simplify structure
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 27, 2016
1 parent 1868ccb commit 6b48b17
Showing 1 changed file with 35 additions and 52 deletions.
87 changes: 35 additions & 52 deletions src/Paket.Core/PackageMetaData.fs
Original file line number Diff line number Diff line change
Expand Up @@ -211,64 +211,47 @@ let findDependencies (dependencies : DependenciesFile) config platform (template
|> LockFile.LoadFrom

let allReferences =
seq {
let getPackages proj =
seq {
let projFileInfo = FileInfo proj.FileName
match ProjectFile.FindReferencesFile projFileInfo with
| Some f ->
let refFile = ReferencesFile.FromFile f

let refs =
refFile.Groups
|> Seq.map (fun kv -> kv.Value.NugetPackages |> List.map (fun p -> kv.Key, p))
|> List.concat
for (group, package) in refs do
yield (group, package, false)
| None -> ignore()
}

let getProjects =
seq {
if includeReferencedProjects then yield! project.GetRecursiveInterProjectDependencies
else yield project
}

for proj in getProjects do
if proj <> project then
let projFileInfo = (FileInfo proj.FileName)
let tf = ProjectFile.FindTemplatesFile projFileInfo
match tf with
| Some t ->
if TemplateFile.IsProjectType tf.Value then
let templateFile = TemplateFile.Load(t, lockFile, None, Seq.empty |> Map.ofSeq)
match templateFile.Contents with
| CompleteInfo(core, optional) ->
yield! getPackages proj
| ProjectInfo(core, optional) ->
let name =
match core.Id with
| Some name -> name
| None -> proj.GetAssemblyName().Replace(".dll","").Replace(".exe","")
let pis : PackageInstallSettings =
{ Name = PackageName name
Settings = InstallSettings.Default }
yield (GroupName("~~referenced-project"), pis, true)
else
let getPackages proj =
let projFileInfo = FileInfo proj.FileName
match ProjectFile.FindReferencesFile projFileInfo with
| Some f ->
let refFile = ReferencesFile.FromFile f
refFile.Groups
|> Seq.map (fun kv -> kv.Value.NugetPackages |> List.map (fun p -> kv.Key, p, false))
|> List.concat
| None -> []

[if includeReferencedProjects then
for proj in project.GetRecursiveInterProjectDependencies |> Seq.filter ((<>) project) do
let projFileInfo = FileInfo proj.FileName
match ProjectFile.FindTemplatesFile projFileInfo with
| Some templateFileName ->
if TemplateFile.IsProjectType templateFileName then
let templateFile = TemplateFile.Load(templateFileName, lockFile, None, Seq.empty |> Map.ofSeq)
match templateFile.Contents with
| CompleteInfo(core, optional) ->
yield! getPackages proj
| None ->
| ProjectInfo(core, optional) ->
let name =
match core.Id with
| Some name -> name
| None -> proj.GetAssemblyName().Replace(".dll","").Replace(".exe","")
let settings : PackageInstallSettings =
{ Name = PackageName name
Settings = InstallSettings.Default }
yield GroupName("~~referenced-project"), settings, true
else
yield! getPackages proj
else
| None ->
yield! getPackages proj
}

yield! getPackages project]

let refs = allReferences |> Seq.toArray
match refs.Length with
| 0 -> withDepsAndIncluded
match allReferences with
| [] -> withDepsAndIncluded
| _ ->
let deps =
refs
|> Array.toList
allReferences
|> List.filter (fun (groupName, np, isReferencedProject) ->
if isReferencedProject then true
else
Expand Down

0 comments on commit 6b48b17

Please sign in to comment.