From 03a6f97498d35ee5e61ae5fbd70907d64577b9bf Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sun, 1 Feb 2015 15:51:43 +0100 Subject: [PATCH 1/3] Install props files to the project - references #516 --- src/Paket.Core/InstallModel.fs | 87 +++++++++++++------ src/Paket.Core/InstallProcess.fs | 7 +- src/Paket.Core/NuGetV2.fs | 23 ++++- src/Paket.Core/ProjectFile.fs | 75 +++++++++++++--- src/Paket.Core/RestoreProcess.fs | 6 +- src/Paket.Core/Utils.fs | 11 +++ src/Paket/Paket.fsproj | 2 +- .../InstallModel/Xml/FSharp.Data.SqlClient.fs | 3 +- .../Paket.Tests/InstallModel/Xml/Fantomas.fs | 7 +- .../InstallModel/Xml/FantomasLib.fs | 3 +- tests/Paket.Tests/InstallModel/Xml/Fuchu.fs | 3 +- .../InstallModel/Xml/ManualNodes.fs | 3 + tests/Paket.Tests/InstallModel/Xml/Plossum.fs | 3 +- tests/Paket.Tests/InstallModel/Xml/RxXaml.fs | 3 +- .../InstallModel/Xml/System.Spatial.fs | 5 +- .../InstallModel/Xml/SystemNetHttp.fs | 3 +- .../InstallModel/Xml/SystemNetHttpForNet4.fs | 3 +- ...mNetHttpWithExistingFrameworkReferences.fs | 3 +- .../SystemNetHttpWithFrameworkReferences.fs | 3 +- .../InstallModel/Xml/xunit.runner.fs | 44 ++++++++++ tests/Paket.Tests/Paket.Tests.fsproj | 3 +- 21 files changed, 243 insertions(+), 57 deletions(-) create mode 100644 tests/Paket.Tests/InstallModel/Xml/xunit.runner.fs diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index 64f6d2db00..cbc91d36cd 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -10,6 +10,7 @@ open Paket.Requirements [] type Reference = | Library of string + | TargetsFile of string | FrameworkAssemblyReference of string member this.LibName = @@ -21,20 +22,24 @@ type Reference = member this.FrameworkReferenceName = match this with - | FrameworkAssemblyReference name -> Some name + | Reference.FrameworkAssemblyReference name -> Some name | _ -> None member this.ReferenceName = match this with - | FrameworkAssemblyReference name -> name + | Reference.FrameworkAssemblyReference name -> name + | Reference.TargetsFile targetsFile -> + let fi = new FileInfo(normalizePath targetsFile) + fi.Name.Replace(fi.Extension, "") | Reference.Library lib -> let fi = new FileInfo(normalizePath lib) fi.Name.Replace(fi.Extension, "") member this.Path = match this with - | Library path -> path - | FrameworkAssemblyReference path -> path + | Reference.Library path -> path + | Reference.TargetsFile path -> path + | Reference.FrameworkAssemblyReference path -> path type InstallFiles = { References : Reference Set @@ -49,6 +54,9 @@ type InstallFiles = member this.AddReference lib = { this with References = Set.add (Reference.Library lib) this.References } + member this.AddTargetsFile targetsFile = + { this with References = Set.add (Reference.TargetsFile targetsFile) this.References } + member this.AddFrameworkAssemblyReference assemblyName = { this with References = Set.add (Reference.FrameworkAssemblyReference assemblyName) this.References } @@ -57,7 +65,7 @@ type InstallFiles = |> Set.map (fun r -> r.FrameworkReferenceName) |> Seq.choose id - member this.MergeWith(that:InstallFiles)= + member this.MergeWith(that:InstallFiles) = { this with References = Set.union that.References this.References ContentFiles = Set.union that.ContentFiles this.ContentFiles } @@ -114,24 +122,34 @@ type InstallModel = |> Seq.toList { this with LibFolders = libFolders} + + member this.AddBuildFolders(libs : seq) : InstallModel = + let libFolders = + libs + |> Seq.map this.ExtractBuildFolder + |> Seq.choose id + |> Seq.distinct + |> List.ofSeq + + if libFolders.Length = 0 then this + else + let libFolders = + PlatformMatching.getSupportedTargetProfiles libFolders + |> Seq.map (fun entry -> { Name = entry.Key; Targets = entry.Value; Files = InstallFiles.empty }) + |> Seq.toList + + { this with LibFolders = libFolders} - member this.ExtractLibFolder(path : string) : string option= - let path = path.Replace("\\", "/").ToLower() - let fi = new FileInfo(path) + member this.ExtractLibFolder path = Utils.extractPath "lib" path - let startPos = path.LastIndexOf("lib/") - let endPos = path.IndexOf('/', startPos + 4) - if startPos < 0 then None - elif endPos < 0 then Some("") - else - Some(path.Substring(startPos + 4, endPos - startPos - 4)) + member this.ExtractBuildFolder path = Utils.extractPath "build" path member this.MapFolders(mapF) = { this with LibFolders = List.map mapF this.LibFolders } member this.MapFiles(mapF) = this.MapFolders(fun folder -> { folder with Files = mapF folder.Files }) - member this.AddPackageFiles(path : LibFolder, file : string, references) : InstallModel = + member this.AddPackageFile(path : LibFolder, file : string, references) : InstallModel = let install = match references with | NuspecReferences.All -> true @@ -139,23 +157,40 @@ type InstallModel = if not install then this else - let folders = List.map (fun p -> + let folders = + this.LibFolders + |> List.map (fun p -> if p.Name = path.Name then { p with Files = p.Files.AddReference file } - else p) this.LibFolders + else p) + { this with LibFolders = folders } - member this.AddFiles(files : seq, references) : InstallModel = + member this.AddReferences(libs, references) : InstallModel = Seq.fold (fun model file -> match model.ExtractLibFolder file with | Some folderName -> match Seq.tryFind (fun folder -> folder.Name = folderName) model.LibFolders with - | Some path -> model.AddPackageFiles(path, file, references) + | Some path -> model.AddPackageFile(path, file, references) | _ -> model - | None -> model) this files + | None -> model) (this.AddLibFolders(libs)) libs + + member this.AddTargetsFile(path : LibFolder, file : string) : InstallModel = + let folders = + this.LibFolders + |> List.map (fun p -> + if p.Name = path.Name then { p with Files = p.Files.AddTargetsFile file } + else p) + { this with LibFolders = folders } - member this.AddReferences(libs, references) : InstallModel = - this.AddLibFolders(libs) - .AddFiles(libs, references) + + member this.AddTargetsFiles(libs) : InstallModel = + Seq.fold (fun model file -> + match model.ExtractBuildFolder file with + | Some folderName -> + match Seq.tryFind (fun folder -> folder.Name = folderName) model.LibFolders with + | Some path -> model.AddTargetsFile(path, file) + | _ -> model + | None -> model) (this.AddBuildFolders(libs)) libs member this.AddReferences(libs) = this.AddReferences(libs, NuspecReferences.All) @@ -190,6 +225,7 @@ type InstallModel = member this.FilterBlackList() = let includeLibs = function | Reference.Library lib -> not (lib.EndsWith ".dll" || lib.EndsWith ".exe") + | Reference.TargetsFile targetsFile -> not (targetsFile.EndsWith ".props" || targetsFile.EndsWith ".targets") | _ -> false let excludeSatelliteAssemblies = function @@ -250,15 +286,16 @@ type InstallModel = |> Set.ofList) member this.RemoveIfCompletelyEmpty() = - if Set.isEmpty (this.GetFrameworkAssemblies.Force()) && Set.isEmpty (this.GetReferences.Force()) then + if Set.isEmpty (this.GetFrameworkAssemblies.Force()) && Set.isEmpty (this.GetReferences.Force()) then InstallModel.EmptyModel(this.PackageName,this.PackageVersion) else this - static member CreateFromLibs(packageName, packageVersion, frameworkRestrictions:FrameworkRestrictions, libs, nuspec : Nuspec) = + static member CreateFromLibs(packageName, packageVersion, frameworkRestrictions:FrameworkRestrictions, libs, targetsFiles, nuspec : Nuspec) = InstallModel .EmptyModel(packageName, packageVersion) .AddReferences(libs, nuspec.References) + .AddTargetsFiles(targetsFiles) .AddFrameworkAssemblyReferences(nuspec.FrameworkAssemblyReferences) .FilterBlackList() .ApplyFrameworkRestrictions(frameworkRestrictions) diff --git a/src/Paket.Core/InstallProcess.fs b/src/Paket.Core/InstallProcess.fs index 2942e61669..b18f0a3835 100644 --- a/src/Paket.Core/InstallProcess.fs +++ b/src/Paket.Core/InstallProcess.fs @@ -71,12 +71,13 @@ let private removeCopiedFiles (project: ProjectFile) = let CreateInstallModel(root, sources, force, package) = async { - let! (package, files) = RestoreProcess.ExtractPackage(root, sources, force, package) + let! (package, files, targetsFiles) = RestoreProcess.ExtractPackage(root, sources, force, package) let (PackageName name) = package.Name let nuspec = FileInfo(sprintf "%s/packages/%s/%s.nuspec" root name name) let nuspec = Nuspec.Load nuspec.FullName - let files = files |> Seq.map (fun fi -> fi.FullName) - return package, InstallModel.CreateFromLibs(package.Name, package.Version, package.FrameworkRestrictions, files, nuspec) + let files = files |> Array.map (fun fi -> fi.FullName) + let targetsFiles = targetsFiles |> Array.map (fun fi -> fi.FullName) + return package, InstallModel.CreateFromLibs(package.Name, package.Version, package.FrameworkRestrictions, files, targetsFiles, nuspec) } /// Restores the given packages from the lock file. diff --git a/src/Paket.Core/NuGetV2.fs b/src/Paket.Core/NuGetV2.fs index e44145edef..3dd217fedf 100644 --- a/src/Paket.Core/NuGetV2.fs +++ b/src/Paket.Core/NuGetV2.fs @@ -414,7 +414,7 @@ let DownloadPackage(root, auth, url, name, version:SemVerInfo, force) = } /// Finds all libraries in a nuget package. -let GetLibFiles(targetFolder) = +let GetLibFiles(targetFolder) = let libs = let dir = DirectoryInfo(targetFolder) let libPath = dir.FullName.ToLower() + Path.DirectorySeparatorChar.ToString() + "lib" @@ -434,6 +434,27 @@ let GetLibFiles(targetFolder) = libs +/// Finds all targets files in a nuget package. +let GetTargetsFiles(targetFolder) = + let targetsFiles = + let dir = DirectoryInfo(targetFolder) + let path = dir.FullName.ToLower() + Path.DirectorySeparatorChar.ToString() + "build" + if dir.Exists then + dir.GetDirectories() + |> Array.filter (fun fi -> fi.FullName.ToLower() = path) + |> Array.collect (fun dir -> dir.GetFiles("*.*",SearchOption.AllDirectories)) + else + Array.empty + + if Logging.verbose then + if Array.isEmpty targetsFiles then + verbosefn "No .targets files found in %s" targetFolder + else + let s = String.Join(Environment.NewLine + " - ",targetsFiles |> Array.map (fun l -> l.FullName)) + verbosefn ".targets files found in %s:%s - %s" targetFolder Environment.NewLine s + + targetsFiles + let GetPackageDetails force sources (PackageName package) (version:SemVerInfo) : PackageResolver.PackageDetails= let rec tryNext xs = match xs with diff --git a/src/Paket.Core/ProjectFile.fs b/src/Paket.Core/ProjectFile.fs index 27d2d7bf9c..93fb96a216 100644 --- a/src/Paket.Core/ProjectFile.fs +++ b/src/Paket.Core/ProjectFile.fs @@ -38,6 +38,15 @@ type ProjectFile = if !isPaketNode = paketOnes then yield node] + member private this.FindPaketPrefixNodes() = + let rec subNodes (node:XmlNode) = + [for node in node.ChildNodes do + if node.Name.StartsWith("__paket__") || (node.Name = "Import" && node.Attributes.["Project"].Value.Contains("__paket__")) then + yield node + yield! subNodes node] + + subNodes this.Document + member this.Name = FileInfo(this.FileName).Name member this.GetCustomReferenceAndFrameworkNodes() = this.FindNodes false "Reference" @@ -111,7 +120,7 @@ type ProjectFile = yield node.Attributes.["Include"].InnerText.Split(',').[0] ] member this.DeletePaketNodes(name) = - let nodesToDelete = this.FindPaketNodes(name) + let nodesToDelete = this.FindPaketNodes(name) if nodesToDelete |> Seq.isEmpty |> not then verbosefn " - Deleting Paket %s nodes" name @@ -171,7 +180,10 @@ type ProjectFile = let firstNode = fileItemsInSameDir |> Seq.head firstNode.ParentNode.InsertBefore(paketNode, firstNode) |> ignore + this.DeleteIfEmpty("PropertyGroup") this.DeleteIfEmpty("ItemGroup") + this.DeleteIfEmpty("When") + this.DeleteIfEmpty("Choose") member this.GetCustomModelNodes(model:InstallModel) = let libs = model.GetReferenceNames() @@ -224,33 +236,72 @@ type ProjectFile = |> addChild (this.CreateNode("Paket","True")) |> itemGroup.AppendChild |> ignore + | Reference.TargetsFile _ -> () itemGroup + let createPropertyGroup references = + let propertyGroup = this.CreateNode("PropertyGroup") + + let propertyNames = + references + |> Seq.choose (fun lib -> + match lib with + | Reference.Library _ -> None + | Reference.FrameworkAssemblyReference _ -> None + | Reference.TargetsFile targetsFile -> + let fi = new FileInfo(normalizePath targetsFile) + let propertyName = "__paket__" + fi.Name.ToString().Replace(" ","_").Replace(".","_") + + let node = this.CreateNode propertyName + node.InnerText <- createRelativePath this.FileName fi.FullName + node + |> propertyGroup.AppendChild + |> ignore + Some(propertyName)) + |> Set.ofSeq + + propertyNames,propertyGroup + let conditions = model.LibFolders - |> List.map (fun lib -> PlatformMatching.getCondition lib.Targets,createItemGroup lib.Files.References) - |> List.sortBy fst + |> List.map (fun lib -> PlatformMatching.getCondition lib.Targets,createItemGroup lib.Files.References,createPropertyGroup lib.Files.References) + |> List.sortBy (fun (x,_,_) -> x) match conditions with - | ["$(TargetFrameworkIdentifier) == 'true'",itemGroup] -> itemGroup + | ["$(TargetFrameworkIdentifier) == 'true'",itemGroup,propertyGroup] -> Seq.empty,itemGroup | _ -> let chooseNode = this.CreateNode("Choose") conditions - |> List.map (fun (condition,itemGroup) -> + |> List.map (fun (condition,itemGroup,(propertyNames,propertyGroup)) -> let whenNode = this.CreateNode("When") |> addAttribute "Condition" condition - whenNode.AppendChild(itemGroup) |> ignore + if not itemGroup.IsEmpty then + whenNode.AppendChild(itemGroup) |> ignore + if not <| Set.isEmpty propertyNames then + whenNode.AppendChild(propertyGroup) |> ignore whenNode) |> List.iter(fun node -> chooseNode.AppendChild(node) |> ignore) - chooseNode + let propertyNameNodes = + conditions + |> List.map (fun (_,_,(propertyNames,_)) -> propertyNames) + |> Set.unionMany + |> Seq.map (fun propertyName -> + this.CreateNode("Import") + |> addAttribute "Project" (sprintf "$(%s)" propertyName) + |> addAttribute "Condition" (sprintf "Exists('$(%s)')" propertyName)) + + propertyNameNodes,chooseNode member this.UpdateReferences(completeModel: Map, usedPackages : Map, hard) = - this.DeletePaketNodes("Reference") + this.DeletePaketNodes("Reference") + + for node in this.FindPaketPrefixNodes() do + node.ParentNode.RemoveChild(node) |> ignore ["ItemGroup";"When";"Otherwise";"Choose";"When";"Choose"] |> List.iter this.DeleteIfEmpty @@ -263,8 +314,12 @@ type ProjectFile = this.DeleteCustomModelNodes(kv.Value) let package = usedPackages.[kv.Key] this.GenerateXml(kv.Value,package.CopyLocal)) - |> Seq.filter (fun node -> node.ChildNodes.Count > 0) - |> Seq.iter (this.ProjectNode.AppendChild >> ignore) + |> Seq.iter (fun (propertyNameNodes,node) -> + if node.ChildNodes.Count > 0 then + this.ProjectNode.AppendChild node |> ignore + + propertyNameNodes + |> Seq.iter (this.ProjectNode.AppendChild >> ignore)) member this.Save() = if Utils.normalizeXml this.Document <> this.OriginalText then diff --git a/src/Paket.Core/RestoreProcess.fs b/src/Paket.Core/RestoreProcess.fs index c13f778dfe..71594efe68 100644 --- a/src/Paket.Core/RestoreProcess.fs +++ b/src/Paket.Core/RestoreProcess.fs @@ -23,15 +23,15 @@ let ExtractPackage(root, sources, force, package : ResolvedPackage) = | _ -> None) try let! folder = NuGetV2.DownloadPackage(root, auth, source.Url, name, v, force) - return package, NuGetV2.GetLibFiles folder + return package, NuGetV2.GetLibFiles folder, NuGetV2.GetTargetsFiles folder with _ when force = false -> tracefn "Something went wrong with the download of %s %A - automatic retry with --force." name v let! folder = NuGetV2.DownloadPackage(root, auth, source.Url, name, v, true) - return package, NuGetV2.GetLibFiles folder + return package, NuGetV2.GetLibFiles folder, NuGetV2.GetTargetsFiles folder | LocalNuget path -> let packageFile = Path.Combine(root, path, sprintf "%s.%A.nupkg" name v) let! folder = NuGetV2.CopyFromCache(root, packageFile, name, v, force) - return package, NuGetV2.GetLibFiles folder + return package, NuGetV2.GetLibFiles folder, NuGetV2.GetTargetsFiles folder } /// Retores the given packages from the lock file. diff --git a/src/Paket.Core/Utils.fs b/src/Paket.Core/Utils.fs index b4fa273aa0..a44b2656e1 100644 --- a/src/Paket.Core/Utils.fs +++ b/src/Paket.Core/Utils.fs @@ -59,6 +59,17 @@ let inline createRelativePath root path = let uri = Uri(basePath) uri.MakeRelativeUri(Uri(path)).ToString().Replace("/", "\\").Replace("%20", " ") +let extractPath infix (fileName : string) : string option= + let path = fileName.Replace("\\", "/").ToLower() + let fi = new FileInfo(path) + + let startPos = path.LastIndexOf(sprintf "%s/" infix) + let endPos = path.IndexOf('/', startPos + infix.Length + 1) + if startPos < 0 then None + elif endPos < 0 then Some("") + else + Some(path.Substring(startPos + infix.Length + 1, endPos - startPos - infix.Length - 1)) + /// [omit] let inline normalizeXml(doc:XmlDocument) = use stringWriter = new StringWriter() diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index 0a71588ca0..e09ef490a7 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -30,7 +30,7 @@ update Project paket.exe - c:\code\paketkopie + d:\code\paketkopie pdbonly diff --git a/tests/Paket.Tests/InstallModel/Xml/FSharp.Data.SqlClient.fs b/tests/Paket.Tests/InstallModel/Xml/FSharp.Data.SqlClient.fs index 11c4838a55..ee1c1ef2e7 100644 --- a/tests/Paket.Tests/InstallModel/Xml/FSharp.Data.SqlClient.fs +++ b/tests/Paket.Tests/InstallModel/Xml/FSharp.Data.SqlClient.fs @@ -35,9 +35,10 @@ let ``should generate Xml for FSharp.Data.SqlClient 1.4.4``() = @"..\FSharp.Data.SqlClient\lib\net40\FSharp.Data.SqlClient.XML" @"..\FSharp.Data.SqlClient\lib\net40\Microsoft.SqlServer.TransactSql.ScriptDom.dll" @"..\FSharp.Data.SqlClient\lib\net40\Microsoft.SqlServer.Types.dll" ], + [], Nuspec.Load("Nuspec/FSharp.Data.SqlClient.nuspec")) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/Fantomas.fs b/tests/Paket.Tests/InstallModel/Xml/Fantomas.fs index bf4487dde9..1e18646b77 100644 --- a/tests/Paket.Tests/InstallModel/Xml/Fantomas.fs +++ b/tests/Paket.Tests/InstallModel/Xml/Fantomas.fs @@ -23,12 +23,15 @@ let ``should generate Xml for Fantomas 1.5``() = [ @"..\Fantomas\lib\FantomasLib.dll" @"..\Fantomas\lib\FSharp.Core.dll" @"..\Fantomas\lib\Fantomas.exe" ], + [], Nuspec.Explicit ["FantomasLib.dll"]) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let propertyNodes,chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) + + propertyNodes |> Seq.length |> shouldEqual 0 let emptyDoc = """ @@ -55,6 +58,7 @@ let ``should generate full Xml for Fantomas 1.5``() = [ @"..\Fantomas\lib\FantomasLib.dll" @"..\Fantomas\lib\FSharp.Core.dll" @"..\Fantomas\lib\Fantomas.exe" ], + [], Nuspec.Explicit ["FantomasLib.dll"]) let project = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value @@ -74,6 +78,7 @@ let ``should not generate full Xml for Fantomas 1.5 if not referenced``() = [ @"..\Fantomas\lib\FantomasLib.dll" @"..\Fantomas\lib\FSharp.Core.dll" @"..\Fantomas\lib\Fantomas.exe" ], + [], Nuspec.Explicit ["FantomasLib.dll"]) let project = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value diff --git a/tests/Paket.Tests/InstallModel/Xml/FantomasLib.fs b/tests/Paket.Tests/InstallModel/Xml/FantomasLib.fs index be9f332812..2ef1ae8751 100644 --- a/tests/Paket.Tests/InstallModel/Xml/FantomasLib.fs +++ b/tests/Paket.Tests/InstallModel/Xml/FantomasLib.fs @@ -23,9 +23,10 @@ let ``should generate Xml for Fantomas 1.5``() = [ @"..\Fantomas\Lib\FantomasLib.dll" @"..\Fantomas\Lib\FSharp.Core.dll" @"..\Fantomas\Lib\Fantomas.exe" ], + [], Nuspec.Explicit ["FantomasLib.dll"]) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.False) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.False) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/Fuchu.fs b/tests/Paket.Tests/InstallModel/Xml/Fuchu.fs index dec4557b6a..09533a6a35 100644 --- a/tests/Paket.Tests/InstallModel/Xml/Fuchu.fs +++ b/tests/Paket.Tests/InstallModel/Xml/Fuchu.fs @@ -23,9 +23,10 @@ let ``should generate Xml for Fuchu 0.4``() = [ @"..\Fuchu\lib\Fuchu.dll" @"..\Fuchu\lib\Fuchu.XML" @"..\Fuchu\lib\Fuchu.pdb" ], + [], Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/ManualNodes.fs b/tests/Paket.Tests/InstallModel/Xml/ManualNodes.fs index 7df79c0915..abf92cd0fa 100644 --- a/tests/Paket.Tests/InstallModel/Xml/ManualNodes.fs +++ b/tests/Paket.Tests/InstallModel/Xml/ManualNodes.fs @@ -13,6 +13,7 @@ let ``should find custom nodes in doc``() = [ @"..\Fantomas\lib\FantomasLib.dll" @"..\Fantomas\lib\FSharp.Core.dll" @"..\Fantomas\lib\Fantomas.exe" ], + [], Nuspec.Explicit ["FantomasLib.dll"]) ProjectFile.Load("./ProjectFile/TestData/CustomFantomasNode.fsprojtest").Value.GetCustomModelNodes(model).IsEmpty @@ -26,6 +27,7 @@ let ``should not find custom nodes if there are none``() = [ @"..\Fantomas\lib\FantomasLib.dll" @"..\Fantomas\lib\FSharp.Core.dll" @"..\Fantomas\lib\Fantomas.exe" ], + [], Nuspec.Explicit ["FantomasLib.dll"]) ProjectFile.Load("./ProjectFile/TestData/NoCustomFantomasNode.fsprojtest").Value.GetCustomModelNodes(model).IsEmpty @@ -39,6 +41,7 @@ let ``should delete custom nodes if there are some``() = [ @"..\Fantomas\lib\FantomasLib.dll" @"..\Fantomas\lib\FSharp.Core.dll" @"..\Fantomas\lib\Fantomas.exe" ], + [], Nuspec.Explicit ["FantomasLib.dll"]) let project = ProjectFile.Load("./ProjectFile/TestData/CustomFantomasNode.fsprojtest").Value diff --git a/tests/Paket.Tests/InstallModel/Xml/Plossum.fs b/tests/Paket.Tests/InstallModel/Xml/Plossum.fs index 77d6aaa36a..3f2203957f 100644 --- a/tests/Paket.Tests/InstallModel/Xml/Plossum.fs +++ b/tests/Paket.Tests/InstallModel/Xml/Plossum.fs @@ -25,9 +25,10 @@ let ``should generate Xml for Plossum``() = let model = InstallModel.CreateFromLibs(PackageName "Plossum.CommandLine", SemVer.Parse "1.5.0", [], [ @"..\Plossum.CommandLine\lib\net40\Plossum CommandLine.dll" ], + [], Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) \ No newline at end of file diff --git a/tests/Paket.Tests/InstallModel/Xml/RxXaml.fs b/tests/Paket.Tests/InstallModel/Xml/RxXaml.fs index 67dbf675e6..351258df7c 100644 --- a/tests/Paket.Tests/InstallModel/Xml/RxXaml.fs +++ b/tests/Paket.Tests/InstallModel/Xml/RxXaml.fs @@ -97,6 +97,7 @@ let ``should generate Xml for Rx-XAML 2.2.4 with correct framework assembly refe @"..\Rx-XAML\lib\windows8\System.Reactive.Windows.Threading.dll" @"..\Rx-XAML\lib\windowsphone8\System.Reactive.Windows.Threading.dll" @"..\Rx-XAML\lib\windowsphone71\System.Reactive.Windows.Threading.dll" ], + [], { References = NuspecReferences.All OfficialName = "Reactive Extensions - XAML Support Library" Dependencies = [] @@ -106,7 +107,7 @@ let ``should generate Xml for Rx-XAML 2.2.4 with correct framework assembly refe { AssemblyName = "System.Windows"; FrameworkRestrictions = [FrameworkRestriction.Exactly(Silverlight "v5.0")] } { AssemblyName = "System.Windows"; FrameworkRestrictions = [FrameworkRestriction.Exactly(WindowsPhoneSilverlight "v7.1")] }]}) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/System.Spatial.fs b/tests/Paket.Tests/InstallModel/Xml/System.Spatial.fs index 131a764538..2cf1c6c958 100644 --- a/tests/Paket.Tests/InstallModel/Xml/System.Spatial.fs +++ b/tests/Paket.Tests/InstallModel/Xml/System.Spatial.fs @@ -42,10 +42,9 @@ let ``should generate Xml for System.Spatial``() = @"..\System.Spatial\lib\sl4\de\System.Spatial.resources.dll" @"..\System.Spatial\lib\sl4\es\System.Spatial.resources.dll" @"..\System.Spatial\lib\sl4\zh-Hans\System.Spatial.resources.dll" - ], - Nuspec.All) + ],[],Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) \ No newline at end of file diff --git a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttp.fs b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttp.fs index 29eafdfcee..9efe064d0e 100644 --- a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttp.fs +++ b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttp.fs @@ -168,9 +168,10 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Extensions.dll" @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Primitives.dll" ], + [], Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpForNet4.fs b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpForNet4.fs index fb84403f6b..4d65027955 100644 --- a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpForNet4.fs +++ b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpForNet4.fs @@ -65,9 +65,10 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Extensions.dll" @"..\Microsoft.Net.Http\lib\wpa81\System.Net.Http.Primitives.dll" ], + [], Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithExistingFrameworkReferences.fs b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithExistingFrameworkReferences.fs index a020411d1c..85cbcd5e70 100644 --- a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithExistingFrameworkReferences.fs +++ b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithExistingFrameworkReferences.fs @@ -58,6 +58,7 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Extensions.dll" @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Primitives.dll"], + [], { References = NuspecReferences.All OfficialName = "Microsoft.Net.Http" Dependencies = [] @@ -65,7 +66,7 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = [{ AssemblyName = "System.Net.Http"; FrameworkRestrictions = [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5))] } { AssemblyName = "System.Net.Http.WebRequest"; FrameworkRestrictions = [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5))] }]}) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/FrameworkAssemblies.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/FrameworkAssemblies.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithFrameworkReferences.fs b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithFrameworkReferences.fs index 04df8675d7..5406cb1f8f 100644 --- a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithFrameworkReferences.fs +++ b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithFrameworkReferences.fs @@ -66,6 +66,7 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Extensions.dll" @"..\Microsoft.Net.Http\lib\net45\System.Net.Http.Primitives.dll"], + [], { References = NuspecReferences.All OfficialName = "Microsoft.Net.Http" Dependencies = [] @@ -73,7 +74,7 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = [{ AssemblyName = "System.Net.Http"; FrameworkRestrictions = [FrameworkRestriction.AtLeast(DotNetFramework(FrameworkVersion.V4_5))] } { AssemblyName = "System.Net.Http.WebRequest"; FrameworkRestrictions = [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5))] }]}) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/xunit.runner.fs b/tests/Paket.Tests/InstallModel/Xml/xunit.runner.fs new file mode 100644 index 0000000000..6cae80485a --- /dev/null +++ b/tests/Paket.Tests/InstallModel/Xml/xunit.runner.fs @@ -0,0 +1,44 @@ +module Paket.InstallModel.Xml.XUniRunnerSpecs + +open Paket +open NUnit.Framework +open FsUnit +open Paket.TestHelpers +open Paket.Domain +open Paket.Requirements + +let expected = """ + + + + <__paket__xunit_runner_visualstudio_props>..\..\..\xunit.runner.visualstudio\build\net20\xunit.runner.visualstudio.props + + + + + <__paket__xunit_runner_visualstudio_props>..\..\..\xunit.runner.visualstudio\build\portable-net45+aspnetcore50+win+wpa81+wp80+monotouch+monoandroid\xunit.runner.visualstudio.props + + +""" + +let expectedPropertyNdoes = """ +""" + +[] +let ``should generate Xml for xunit.runner.visualstudio 2.0.0``() = + let model = + InstallModel.CreateFromLibs(PackageName "xunit.runner.visualstudio", SemVer.Parse "2.50.0", [],[], + [ @"..\xunit.runner.visualstudio\build\net20\xunit.runner.visualstudio.props" + @"..\xunit.runner.visualstudio\build\portable-net45+aspnetcore50+win+wpa81+wp80+monotouch+monoandroid\xunit.runner.visualstudio.props" ], + Nuspec.All) + + let propertyNodes,chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + chooseNode.OuterXml + |> normalizeXml + |> shouldEqual (normalizeXml expected) + + propertyNodes |> Seq.length |> shouldEqual 1 + + (propertyNodes |> Seq.head).OuterXml + |> normalizeXml + |> shouldEqual (normalizeXml expectedPropertyNdoes) \ No newline at end of file diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index 405ef20155..d7c0f93149 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -1,4 +1,4 @@ - + @@ -209,6 +209,7 @@ + From adc75bbcbc188e120db80e1cfbf6e19180d07cde Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Mon, 2 Feb 2015 18:54:23 +0100 Subject: [PATCH 2/3] Make endings case-insensitive because of StyleCop.MSBuild --- src/Paket.Core/InstallModel.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index cbc91d36cd..dec96538bd 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -224,8 +224,8 @@ type InstallModel = member this.FilterBlackList() = let includeLibs = function - | Reference.Library lib -> not (lib.EndsWith ".dll" || lib.EndsWith ".exe") - | Reference.TargetsFile targetsFile -> not (targetsFile.EndsWith ".props" || targetsFile.EndsWith ".targets") + | Reference.Library lib -> not (lib.ToLower().EndsWith ".dll" || lib.ToLower().EndsWith ".exe") + | Reference.TargetsFile targetsFile -> not (targetsFile.ToLower().EndsWith ".props" || targetsFile.ToLower().EndsWith ".targets") | _ -> false let excludeSatelliteAssemblies = function From 834787bd8e078ee4bfc24281547de5ee348b5b6a Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 3 Feb 2015 10:45:27 +0100 Subject: [PATCH 3/3] Allow to reference StyleCop.MSBuild targets files - references #516 --- RELEASE_NOTES.md | 3 + src/Paket.Core/InstallModel.fs | 10 +++ src/Paket.Core/ProjectFile.fs | 64 +++++++++++-------- .../InstallModel/ProcessingSpecs.fs | 20 +++++- .../InstallModel/Xml/FSharp.Data.SqlClient.fs | 2 +- .../Paket.Tests/InstallModel/Xml/Fantomas.fs | 2 +- .../InstallModel/Xml/FantomasLib.fs | 2 +- tests/Paket.Tests/InstallModel/Xml/Fuchu.fs | 2 +- tests/Paket.Tests/InstallModel/Xml/Plossum.fs | 2 +- tests/Paket.Tests/InstallModel/Xml/RxXaml.fs | 2 +- .../InstallModel/Xml/System.Spatial.fs | 2 +- .../InstallModel/Xml/SystemNetHttp.fs | 2 +- .../InstallModel/Xml/SystemNetHttpForNet4.fs | 2 +- ...mNetHttpWithExistingFrameworkReferences.fs | 2 +- .../SystemNetHttpWithFrameworkReferences.fs | 2 +- .../InstallModel/Xml/xunit.runner.fs | 4 +- tests/Paket.Tests/Paket.Tests.fsproj | 1 + 17 files changed, 82 insertions(+), 42 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 76cd636cec..039efbd2db 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.27.0-alpha001 - 03.02.2015 +* Allow to reference `.props` and `.targets` files - https://github.com/fsprojects/Paket/issues/516 + #### 0.26.4 - 02.02.2015 * Create a install function in the api which takes a `paket.dependencies` file as text - https://github.com/fsprojects/Paket/issues/576 diff --git a/src/Paket.Core/InstallModel.fs b/src/Paket.Core/InstallModel.fs index dec96538bd..7db33dcbc0 100644 --- a/src/Paket.Core/InstallModel.fs +++ b/src/Paket.Core/InstallModel.fs @@ -105,6 +105,16 @@ type InstallModel = | _ -> None) |> Seq.choose id | None -> Seq.empty + + member this.GetTargetsFiles(target : TargetProfile) = + match Seq.tryFind (fun lib -> Seq.exists (fun t -> t = target) lib.Targets) this.LibFolders with + | Some folder -> folder.Files.References + |> Set.map (fun x -> + match x with + | Reference.TargetsFile targetsFile -> Some targetsFile + | _ -> None) + |> Seq.choose id + | None -> Seq.empty member this.AddLibFolders(libs : seq) : InstallModel = let libFolders = diff --git a/src/Paket.Core/ProjectFile.fs b/src/Paket.Core/ProjectFile.fs index 93fb96a216..4c521b7f26 100644 --- a/src/Paket.Core/ProjectFile.fs +++ b/src/Paket.Core/ProjectFile.fs @@ -267,34 +267,38 @@ type ProjectFile = |> List.map (fun lib -> PlatformMatching.getCondition lib.Targets,createItemGroup lib.Files.References,createPropertyGroup lib.Files.References) |> List.sortBy (fun (x,_,_) -> x) - match conditions with - | ["$(TargetFrameworkIdentifier) == 'true'",itemGroup,propertyGroup] -> Seq.empty,itemGroup - | _ -> - let chooseNode = this.CreateNode("Choose") + let chooseNode,additionalPropertyGroup = + match conditions with + | ["$(TargetFrameworkIdentifier) == 'true'",itemGroup,(propertyNames,propertyGroup)] -> itemGroup,if Set.isEmpty propertyNames then None else Some propertyGroup + | _ -> + let chooseNode = this.CreateNode("Choose") - conditions - |> List.map (fun (condition,itemGroup,(propertyNames,propertyGroup)) -> - let whenNode = - this.CreateNode("When") - |> addAttribute "Condition" condition - - if not itemGroup.IsEmpty then - whenNode.AppendChild(itemGroup) |> ignore - if not <| Set.isEmpty propertyNames then - whenNode.AppendChild(propertyGroup) |> ignore - whenNode) - |> List.iter(fun node -> chooseNode.AppendChild(node) |> ignore) - - let propertyNameNodes = conditions - |> List.map (fun (_,_,(propertyNames,_)) -> propertyNames) - |> Set.unionMany - |> Seq.map (fun propertyName -> - this.CreateNode("Import") - |> addAttribute "Project" (sprintf "$(%s)" propertyName) - |> addAttribute "Condition" (sprintf "Exists('$(%s)')" propertyName)) - - propertyNameNodes,chooseNode + |> List.map (fun (condition,itemGroup,(propertyNames,propertyGroup)) -> + let whenNode = + this.CreateNode("When") + |> addAttribute "Condition" condition + + if not itemGroup.IsEmpty then + whenNode.AppendChild(itemGroup) |> ignore + if not <| Set.isEmpty propertyNames then + whenNode.AppendChild(propertyGroup) |> ignore + whenNode) + |> List.iter(fun node -> chooseNode.AppendChild(node) |> ignore) + + chooseNode,None + + let propertyNameNodes = + conditions + |> List.map (fun (_,_,(propertyNames,_)) -> propertyNames) + |> Set.unionMany + |> Seq.map (fun propertyName -> + this.CreateNode("Import") + |> addAttribute "Project" (sprintf "$(%s)" propertyName) + |> addAttribute "Condition" (sprintf "Exists('$(%s)')" propertyName)) + |> Seq.toList + + propertyNameNodes,chooseNode,additionalPropertyGroup member this.UpdateReferences(completeModel: Map, usedPackages : Map, hard) = @@ -314,10 +318,14 @@ type ProjectFile = this.DeleteCustomModelNodes(kv.Value) let package = usedPackages.[kv.Key] this.GenerateXml(kv.Value,package.CopyLocal)) - |> Seq.iter (fun (propertyNameNodes,node) -> - if node.ChildNodes.Count > 0 then + |> Seq.iter (fun (propertyNameNodes,node,additionalPropertyGroup) -> + if node.ChildNodes.Count > 0 then this.ProjectNode.AppendChild node |> ignore + match additionalPropertyGroup with + | Some node -> this.ProjectNode.AppendChild node |> ignore + | None -> () + propertyNameNodes |> Seq.iter (this.ProjectNode.AppendChild >> ignore)) diff --git a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs index 633e6daee2..c0a195a70f 100644 --- a/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs +++ b/tests/Paket.Tests/InstallModel/ProcessingSpecs.fs @@ -82,8 +82,6 @@ let ``should install single client profile lib for everything``() = let model = emptymodel.AddReferences([ @"..\Castle.Core\lib\net40-client\Castle.Core.dll" ]) - // TODO: not sure it makes sense to include a 4.0 dll into a 3.5 project - // model.GetFiles(SinglePlatform (DotNetFramework FrameworkVersion.V3_5)) |> shouldNotContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" model.GetFiles(SinglePlatform (DotNetFramework FrameworkVersion.V4_Client)) |> shouldContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" model.GetFiles(SinglePlatform (DotNetFramework FrameworkVersion.V4)) |> shouldContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" model.GetFiles(SinglePlatform (DotNetFramework FrameworkVersion.V4_5)) |> shouldContain @"..\Castle.Core\lib\net40-client\Castle.Core.dll" @@ -439,3 +437,21 @@ let ``should not install tools``() = |> Seq.forall (fun folder -> folder.Files.References.IsEmpty) |> shouldEqual true +[] +let ``should handle props files``() = + let model = + emptymodel.AddTargetsFiles( + [ @"..\xunit.runner.visualstudio\build\net20\xunit.runner.visualstudio.props" + @"..\xunit.runner.visualstudio\build\portable-net45+aspnetcore50+win+wpa81+wp80+monotouch+monoandroid\xunit.runner.visualstudio.props" ]) + .FilterBlackList() + + model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\xunit.runner.visualstudio\build\net20\xunit.runner.visualstudio.props" + +[] +let ``should handle Targets files``() = + let model = + emptymodel.AddTargetsFiles( + [ @"..\StyleCop.MSBuild\build\StyleCop.MSBuild.Targets" ]) + .FilterBlackList() + + model.GetTargetsFiles(SinglePlatform (DotNetFramework FrameworkVersion.V2)) |> shouldContain @"..\StyleCop.MSBuild\build\StyleCop.MSBuild.Targets" \ No newline at end of file diff --git a/tests/Paket.Tests/InstallModel/Xml/FSharp.Data.SqlClient.fs b/tests/Paket.Tests/InstallModel/Xml/FSharp.Data.SqlClient.fs index ee1c1ef2e7..0cd4e5f50d 100644 --- a/tests/Paket.Tests/InstallModel/Xml/FSharp.Data.SqlClient.fs +++ b/tests/Paket.Tests/InstallModel/Xml/FSharp.Data.SqlClient.fs @@ -38,7 +38,7 @@ let ``should generate Xml for FSharp.Data.SqlClient 1.4.4``() = [], Nuspec.Load("Nuspec/FSharp.Data.SqlClient.nuspec")) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/Fantomas.fs b/tests/Paket.Tests/InstallModel/Xml/Fantomas.fs index 1e18646b77..5898c60907 100644 --- a/tests/Paket.Tests/InstallModel/Xml/Fantomas.fs +++ b/tests/Paket.Tests/InstallModel/Xml/Fantomas.fs @@ -26,7 +26,7 @@ let ``should generate Xml for Fantomas 1.5``() = [], Nuspec.Explicit ["FantomasLib.dll"]) - let propertyNodes,chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let propertyNodes,chooseNode,additionalNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/FantomasLib.fs b/tests/Paket.Tests/InstallModel/Xml/FantomasLib.fs index 2ef1ae8751..7a797e3c54 100644 --- a/tests/Paket.Tests/InstallModel/Xml/FantomasLib.fs +++ b/tests/Paket.Tests/InstallModel/Xml/FantomasLib.fs @@ -26,7 +26,7 @@ let ``should generate Xml for Fantomas 1.5``() = [], Nuspec.Explicit ["FantomasLib.dll"]) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.False) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.False) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/Fuchu.fs b/tests/Paket.Tests/InstallModel/Xml/Fuchu.fs index 09533a6a35..a554282ac8 100644 --- a/tests/Paket.Tests/InstallModel/Xml/Fuchu.fs +++ b/tests/Paket.Tests/InstallModel/Xml/Fuchu.fs @@ -26,7 +26,7 @@ let ``should generate Xml for Fuchu 0.4``() = [], Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/Plossum.fs b/tests/Paket.Tests/InstallModel/Xml/Plossum.fs index 3f2203957f..a17d452742 100644 --- a/tests/Paket.Tests/InstallModel/Xml/Plossum.fs +++ b/tests/Paket.Tests/InstallModel/Xml/Plossum.fs @@ -28,7 +28,7 @@ let ``should generate Xml for Plossum``() = [], Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) \ No newline at end of file diff --git a/tests/Paket.Tests/InstallModel/Xml/RxXaml.fs b/tests/Paket.Tests/InstallModel/Xml/RxXaml.fs index 351258df7c..d8ffba6c52 100644 --- a/tests/Paket.Tests/InstallModel/Xml/RxXaml.fs +++ b/tests/Paket.Tests/InstallModel/Xml/RxXaml.fs @@ -107,7 +107,7 @@ let ``should generate Xml for Rx-XAML 2.2.4 with correct framework assembly refe { AssemblyName = "System.Windows"; FrameworkRestrictions = [FrameworkRestriction.Exactly(Silverlight "v5.0")] } { AssemblyName = "System.Windows"; FrameworkRestrictions = [FrameworkRestriction.Exactly(WindowsPhoneSilverlight "v7.1")] }]}) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/System.Spatial.fs b/tests/Paket.Tests/InstallModel/Xml/System.Spatial.fs index 2cf1c6c958..84e0402d2a 100644 --- a/tests/Paket.Tests/InstallModel/Xml/System.Spatial.fs +++ b/tests/Paket.Tests/InstallModel/Xml/System.Spatial.fs @@ -44,7 +44,7 @@ let ``should generate Xml for System.Spatial``() = @"..\System.Spatial\lib\sl4\zh-Hans\System.Spatial.resources.dll" ],[],Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) \ No newline at end of file diff --git a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttp.fs b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttp.fs index 9efe064d0e..59be4e590c 100644 --- a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttp.fs +++ b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttp.fs @@ -171,7 +171,7 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = [], Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpForNet4.fs b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpForNet4.fs index 4d65027955..47083c57bb 100644 --- a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpForNet4.fs +++ b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpForNet4.fs @@ -68,7 +68,7 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = [], Nuspec.All) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithExistingFrameworkReferences.fs b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithExistingFrameworkReferences.fs index 85cbcd5e70..4b35df6ae1 100644 --- a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithExistingFrameworkReferences.fs +++ b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithExistingFrameworkReferences.fs @@ -66,7 +66,7 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = [{ AssemblyName = "System.Net.Http"; FrameworkRestrictions = [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5))] } { AssemblyName = "System.Net.Http.WebRequest"; FrameworkRestrictions = [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5))] }]}) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/FrameworkAssemblies.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/FrameworkAssemblies.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithFrameworkReferences.fs b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithFrameworkReferences.fs index 5406cb1f8f..9b3ba33279 100644 --- a/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithFrameworkReferences.fs +++ b/tests/Paket.Tests/InstallModel/Xml/SystemNetHttpWithFrameworkReferences.fs @@ -74,7 +74,7 @@ let ``should generate Xml for System.Net.Http 2.2.8``() = [{ AssemblyName = "System.Net.Http"; FrameworkRestrictions = [FrameworkRestriction.AtLeast(DotNetFramework(FrameworkVersion.V4_5))] } { AssemblyName = "System.Net.Http.WebRequest"; FrameworkRestrictions = [FrameworkRestriction.Exactly(DotNetFramework(FrameworkVersion.V4_5))] }]}) - let chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) |> snd + let _,chooseNode,_ = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) diff --git a/tests/Paket.Tests/InstallModel/Xml/xunit.runner.fs b/tests/Paket.Tests/InstallModel/Xml/xunit.runner.fs index 6cae80485a..2a9e5cb53e 100644 --- a/tests/Paket.Tests/InstallModel/Xml/xunit.runner.fs +++ b/tests/Paket.Tests/InstallModel/Xml/xunit.runner.fs @@ -32,11 +32,13 @@ let ``should generate Xml for xunit.runner.visualstudio 2.0.0``() = @"..\xunit.runner.visualstudio\build\portable-net45+aspnetcore50+win+wpa81+wp80+monotouch+monoandroid\xunit.runner.visualstudio.props" ], Nuspec.All) - let propertyNodes,chooseNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) + let propertyNodes,chooseNode,additionalNode = ProjectFile.Load("./ProjectFile/TestData/Empty.fsprojtest").Value.GenerateXml(model,CopyLocal.True) chooseNode.OuterXml |> normalizeXml |> shouldEqual (normalizeXml expected) + additionalNode |> shouldEqual None + propertyNodes |> Seq.length |> shouldEqual 1 (propertyNodes |> Seq.head).OuterXml diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index d7c0f93149..768789a558 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -210,6 +210,7 @@ +