Skip to content

Commit

Permalink
Don't reference cli packages
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 5, 2017
1 parent 39bfc10 commit d475b66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/Paket.Core/Installation/RestoreProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ let Restore(dependenciesFileName,projectFile,force,group,referencesFileNames,ign
createAlternativeNuGetConfig alternativeConfigFileName

for kv in groups do
let hull = lockFile.GetOrderedPackageHull(kv.Key,referencesFile)
let hull,cliToolsInGroup = lockFile.GetOrderedPackageHull(kv.Key,referencesFile)
cliTools.AddRange cliToolsInGroup

let depsGroup =
match dependenciesFile.Groups |> Map.tryFind kv.Key with
| Some group -> group
Expand Down Expand Up @@ -319,10 +321,7 @@ let Restore(dependenciesFileName,projectFile,force,group,referencesFileNames,ign
(if direct then "Direct" else "Transitive") + "," +
kv.Key.ToString()

if package.IsCliToolPackage() then
cliTools.Add package
else
list.Add line
list.Add line

let output = String.Join(Environment.NewLine,list)
if output = "" then
Expand Down
26 changes: 20 additions & 6 deletions src/Paket.Core/PaketConfigFiles/LockFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -806,18 +806,32 @@ type LockFile (fileName:string, groups: Map<GroupName,LockFileGroup>) =
let usedPackageKeys = HashSet<_>()
let toVisit = ref Set.empty
let visited = ref Set.empty
let cliTools = ref Set.empty
let resolution =
match this.Groups |> Map.tryFind groupName with
| Some group -> group.Resolution
| None -> failwithf "Error for %s: Group %O can't be found in paket.lock file." referencesFile.FileName groupName

match referencesFile.Groups |> Map.tryFind groupName with
| Some g ->
for p in g.NugetPackages do
let k = groupName,p.Name
if usedPackageKeys.Contains k then
failwithf "Package %O is referenced more than once in %s within group %O." p.Name referencesFile.FileName groupName
usedPackageKeys.Add k |> ignore
let package =
match resolution |> Map.tryFind p.Name with
| Some p -> p
| None -> failwithf "Error for %s: Package %O was not found in group %O of the paket.lock file." referencesFile.FileName p.Name groupName

if package.IsCliToolPackage() then
cliTools := Set.add package !cliTools
else
if usedPackageKeys.Contains k then
failwithf "Package %O is referenced more than once in %s within group %O." p.Name referencesFile.FileName groupName

usedPackageKeys.Add k |> ignore

let deps = this.GetDirectDependenciesOfSafe(groupName,p.Name,referencesFile.FileName)
let deps = this.GetDirectDependenciesOfSafe(groupName,p.Name,referencesFile.FileName)

toVisit := Set.add (k,p,deps) !toVisit
toVisit := Set.add (k,p,deps) !toVisit
| None -> ()

while !toVisit <> Set.empty do
Expand All @@ -842,7 +856,7 @@ type LockFile (fileName:string, groups: Map<GroupName,LockFileGroup>) =
visited :=
!visited
|> Set.remove ((groupName,packageName),p,deps)
|> Set.map (fun ((g,p),b,c) -> if g = groupName then (g,p),b,Set.filter ((<>) packageName) c else (g,p),b,c)]
|> Set.map (fun ((g,p),b,c) -> if g = groupName then (g,p),b,Set.filter ((<>) packageName) c else (g,p),b,c)],!cliTools


member this.GetPackageHull(groupName,referencesFile:ReferencesFile) =
Expand Down

0 comments on commit d475b66

Please sign in to comment.