Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] fix 2263: Framework restriction is lost for global build folder #2272

Merged
merged 6 commits into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 5 additions & 5 deletions src/Paket.Core/Files/ProjectFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ module ProjectFile =
if not importTargets then List.empty, List.empty else
let sortedTargets = model.TargetsFileFolders |> List.sortBy (fun lib -> lib.Name)
sortedTargets
|> List.partition (fun lib -> allTargetProfiles = set lib.Targets )
|> List.partition (fun lib -> set lib.Targets |> Set.isSuperset allTargetProfiles)

let frameworkSpecificTargetsFileConditions =
frameworkSpecificTargets
Expand Down 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.AllDotNetStandardProfiles @ KnownTargetProfiles.AllDotNetProfiles)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PLEASE REVIEW: I think we don't care about runtimes when deciding whether to install a .targets / .props, is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref #2238

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 lockFileGroupRestrictions)
}
|]
|> 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
8 changes: 4 additions & 4 deletions tests/Paket.Tests/InstallModel/Xml/Fantomas.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ let ``should generate full Xml for Fantomas 1.5``() =
Nuspec.Explicit ["FantomasLib.dll"])

let project = ProjectFile.TryLoad("./ProjectFile/TestData/Empty.fsprojtest").Value
let completeModel = [(Constants.MainDependencyGroup, (PackageName "Fantomas")),(model,model)] |> Map.ofSeq
let completeModel = [(Constants.MainDependencyGroup, (PackageName "Fantomas")),(model,model,[])] |> Map.ofSeq
let used = [(Constants.MainDependencyGroup, (PackageName "fantoMas")), (InstallSettings.Default,InstallSettings.Default)] |> Map.ofSeq
project.UpdateReferences(".",completeModel,used,used)

Expand All @@ -89,7 +89,7 @@ let ``should not generate full Xml for Fantomas 1.5 if not referenced``() =
Nuspec.Explicit ["FantomasLib.dll"])

let project = ProjectFile.TryLoad("./ProjectFile/TestData/Empty.fsprojtest").Value
let completeModel = [(Constants.MainDependencyGroup, (PackageName "Fantomas")),(model,model)] |> Map.ofSeq
let completeModel = [(Constants.MainDependencyGroup, (PackageName "Fantomas")),(model,model,[])] |> Map.ofSeq
let used = [(Constants.MainDependencyGroup, (PackageName "blub")), (InstallSettings.Default,InstallSettings.Default) ] |> Map.ofSeq
project.UpdateReferences(".",completeModel,used,used)

Expand Down Expand Up @@ -126,7 +126,7 @@ let ``should generate full Xml with reference condition for Fantomas 1.5``() =
Nuspec.Explicit ["FantomasLib.dll"])

let project = ProjectFile.TryLoad("./ProjectFile/TestData/Empty.fsprojtest").Value
let completeModel = [(Constants.MainDependencyGroup, (PackageName "Fantomas")),(model,model)] |> Map.ofSeq
let completeModel = [(Constants.MainDependencyGroup, (PackageName "Fantomas")),(model,model,[])] |> Map.ofSeq
let settings =
{ InstallSettings.Default
with ReferenceCondition = Some "LEGACY" }
Expand Down Expand Up @@ -168,7 +168,7 @@ let ``should generate full Xml with reference condition and framework restrictio
Nuspec.All)

let project = ProjectFile.TryLoad("./ProjectFile/TestData/Empty.fsprojtest").Value
let completeModel = [(Constants.MainDependencyGroup, (PackageName "Fantomas")),(model,model)] |> Map.ofSeq
let completeModel = [(Constants.MainDependencyGroup, (PackageName "Fantomas")),(model,model,[])] |> Map.ofSeq
let settings =
{ InstallSettings.Default
with ReferenceCondition = Some "LEGACY" }
Expand Down