Skip to content

Commit

Permalink
fix #2263
Browse files Browse the repository at this point in the history
use group framework restrictions to decide if a package is global or fw-specific
  • Loading branch information
0x53A committed Apr 23, 2017
1 parent bf89450 commit c161074
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Paket.Core/Files/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ module ProjectFile =

let updateReferences
rootPath
(completeModel: Map<GroupName*PackageName,_*InstallModel>)
(completeModel: Map<GroupName*PackageName,_*InstallModel*FrameworkRestriction list>)
(directPackages : Map<GroupName*PackageName,_*InstallSettings>)
(usedPackages : Map<GroupName*PackageName,_*InstallSettings>)
(project:ProjectFile) =
Expand Down Expand Up @@ -1053,12 +1053,12 @@ module ProjectFile =
|> Seq.filter (fun kv -> usedPackages.ContainsKey kv.Key)
|> Seq.sortBy (fun kv -> let group, packName = kv.Key in group.GetCompareString(), packName.GetCompareString())
|> Seq.map (fun kv ->
deleteCustomModelNodes (snd kv.Value) project
deleteCustomModelNodes (sndOf3 kv.Value) project
let installSettings = snd usedPackages.[kv.Key]
let restrictionList = installSettings.FrameworkRestrictions |> getRestrictionList

let projectModel =
(snd kv.Value)
(sndOf3 kv.Value)
.ApplyFrameworkRestrictions(restrictionList)
.FilterExcludes(installSettings.Excludes)
.RemoveIfCompletelyEmpty()
Expand All @@ -1079,7 +1079,7 @@ module ProjectFile =

let importTargets = defaultArg installSettings.ImportTargets true

let allFrameworks = applyRestrictionsToTargets restrictionList KnownTargetProfiles.AllProfiles
let allFrameworks = applyRestrictionsToTargets ((thirdOf3 kv.Value)) KnownTargetProfiles.AllProfiles
generateXml projectModel usedFrameworkLibs installSettings.Aliases installSettings.CopyLocal importTargets installSettings.ReferenceCondition (set allFrameworks) project)
|> Seq.iter (fun ctx ->
for chooseNode in ctx.ChooseNodes do
Expand Down
30 changes: 20 additions & 10 deletions src/Paket.Core/InstallProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ open Paket.PackageSources
open Paket.PackagesConfigFile
open Paket.Requirements
open System.Collections.Generic
open Paket.ProjectFile
open System.Diagnostics

let updatePackagesConfigFile (model: Map<GroupName*PackageName,SemVerInfo*InstallSettings>) packagesConfigFileName =
let packagesInConfigFile = PackagesConfigFile.Read packagesConfigFileName
Expand Down Expand Up @@ -176,13 +178,21 @@ let CreateModel(alternativeProjectRoot, root, force, dependenciesFile:Dependenci
RemoteDownload.DownloadSourceFiles(root, kv.Key, force, files)

lockFile.Groups
|> Seq.map (fun kv' ->
let sources = dependenciesFile.Groups.[kv'.Key].Sources
let caches = dependenciesFile.Groups.[kv'.Key].Caches
kv'.Value.Resolution
|> Map.filter (fun name _ -> packages.Contains(kv'.Key,name))
|> Seq.map (fun kv -> CreateInstallModel(alternativeProjectRoot, root,kv'.Key,sources,caches,force,kv.Value))
|> Seq.toArray
|> Seq.map (fun kv' ->
let groupName, lockFileGroup = kv'.Key, kv'.Value
let depFileGroup = dependenciesFile.Groups.[groupName]
let sources = depFileGroup.Sources
let caches = depFileGroup.Caches
let depFileGroupRestrictions = depFileGroup.Options.Settings.FrameworkRestrictions
let lockFileGroupRestrictions = lockFileGroup.Options.Settings.FrameworkRestrictions
[| for kv in lockFileGroup.Resolution do
let packageName, resolvedPackage = kv.Key, kv.Value
if packages.Contains(groupName,packageName) then
yield async {
let! (groupName,packageName), (package,model) = CreateInstallModel(alternativeProjectRoot, root,groupName,sources,caches,force,resolvedPackage)
return (groupName,packageName), (package,model, getRestrictionList depFileGroupRestrictions)
}
|]
|> Async.Parallel
|> Async.RunSynchronously)
|> Seq.concat
Expand Down Expand Up @@ -347,7 +357,7 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile

let package =
match model |> Map.tryFind (kv.Key, ps.Name) with
| Some (p,_) -> Choice1Of2 p
| Some (p,_,_) -> Choice1Of2 p
| None -> Choice2Of2 <| sprintf " - %s uses NuGet package %O, but it was not found in the paket.lock file in group %O.%s" referenceFile.FileName ps.Name kv.Key (lockFile.CheckIfPackageExistsInAnyGroup ps.Name)

match group, package with
Expand Down Expand Up @@ -498,7 +508,7 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile

let allKnownLibs =
model
|> Seq.map (fun kv -> (snd kv.Value).GetLibReferencesLazy.Force())
|> Seq.map (fun kv -> (sndOf3 kv.Value).GetLibReferencesLazy.Force())
|> Set.unionMany

for g in lockFile.Groups do
Expand All @@ -511,7 +521,7 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile
|> Map.tryFind (snd kv.Key)
|> Option.bind (fun p -> p.Settings.CreateBindingRedirects)

(snd kv.Value,packageRedirects))
(sndOf3 kv.Value,packageRedirects))
|> applyBindingRedirects
!first
options.CreateNewBindingFiles
Expand Down
4 changes: 4 additions & 0 deletions src/Paket.Core/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ ServicePointManager.SecurityProtocol <- unbox 192 ||| unbox 768 ||| unbox 3072 |
///SecurityProtocolType.Tls ||| SecurityProtocolType.Tls11 ||| SecurityProtocolType.Tls12 ||| SecurityProtocolType.Ssl3
#endif

let sndOf3 (_,v,_) = v
let thirdOf3 (_,_,v) = v


/// Adds quotes around the string
/// [omit]
let quote (str:string) = "\"" + str.Replace("\"","\\\"") + "\""
Expand Down

0 comments on commit c161074

Please sign in to comment.