From 5ef1cc1c8e273a6127c3effb07728a1d806d473a Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 5 Jan 2016 12:13:34 +0100 Subject: [PATCH 1/3] Refactor build actions --- src/Paket.Core/ProjectFile.fs | 31 +++++++++------- .../ProjectFile/FileBuildActionSpecs.fs | 14 ++++---- tests/Paket.Tests/ProjectFile/OutputSpecs.fs | 36 +++++++++---------- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/Paket.Core/ProjectFile.fs b/src/Paket.Core/ProjectFile.fs index ca5bfe2ec4..42bba14099 100644 --- a/src/Paket.Core/ProjectFile.fs +++ b/src/Paket.Core/ProjectFile.fs @@ -9,9 +9,14 @@ open System.Collections.Generic open Paket.Xml open Paket.Requirements +[] +type BuildAction = +| Compile +| Content + /// File item inside of project files. type FileItem = - { BuildAction : string + { BuildAction : BuildAction Include : string Link : string option } @@ -454,16 +459,16 @@ type ProjectFile = let firstItemGroup = this.ProjectNode |> getNodes "ItemGroup" |> List.tryHead match firstItemGroup with | None -> - ["Content", this.CreateNode("ItemGroup") - "Compile", this.CreateNode("ItemGroup") ] + [BuildAction.Content, this.CreateNode("ItemGroup") + BuildAction.Compile, this.CreateNode("ItemGroup") ] | Some node -> - ["Content", node :?> XmlElement - "Compile", node :?> XmlElement ] + [BuildAction.Content, node :?> XmlElement + BuildAction.Compile, node :?> XmlElement ] |> dict for fileItem in fileItems |> List.rev do let libReferenceNode = - this.CreateNode(fileItem.BuildAction) + this.CreateNode(fileItem.BuildAction.ToString()) |> addAttribute "Include" fileItem.Include |> addChild (this.CreateNode("Paket","True")) |> fun n -> match fileItem.Link with @@ -472,7 +477,7 @@ type ProjectFile = let fileItemsInSameDir = this.Document - |> getDescendants fileItem.BuildAction + |> getDescendants (fileItem.BuildAction.ToString()) |> List.filter (fun node -> match node |> getAttribute "Include" with | Some path when path.StartsWith(Path.GetDirectoryName(fileItem.Include)) -> true @@ -538,7 +543,7 @@ type ProjectFile = if nodesToDelete <> [] then verbosefn " - Deleting custom projects nodes for %O" model.PackageName - for node in nodesToDelete do + for node in nodesToDelete do node.ParentNode.RemoveChild(node) |> ignore member private this.GenerateAnalyzersXml(model:InstallModel) = @@ -726,16 +731,16 @@ type ProjectFile = this.DeletePaketNodes("Analyzer") this.DeletePaketNodes("Reference") - let rec PaketNodes (node:XmlNode) = + let rec getPaketNodes (node:XmlNode) = [for node in node.ChildNodes do if node.Name.Contains("__paket__") || (node.Name = "Import" && match node |> getAttribute "Project" with Some v -> v.Contains("__paket__") | None -> false) || (node |> withAttributeValue "Label" "Paket") then yield node - yield! PaketNodes node] + yield! getPaketNodes node] - for node in PaketNodes this.Document do + for node in getPaketNodes this.Document do let parent = node.ParentNode try node.ParentNode.RemoveChild(node) |> ignore @@ -981,8 +986,8 @@ type ProjectFile = member this.DetermineBuildAction fileName = if Path.GetExtension(this.FileName) = Path.GetExtension(fileName) + "proj" - then "Compile" - else "Content" + then BuildAction.Compile + else BuildAction.Content member this.GetOutputDirectory buildConfiguration buildPlatform = let platforms = diff --git a/tests/Paket.Tests/ProjectFile/FileBuildActionSpecs.fs b/tests/Paket.Tests/ProjectFile/FileBuildActionSpecs.fs index 258d95a7cf..dec7d3e8b0 100644 --- a/tests/Paket.Tests/ProjectFile/FileBuildActionSpecs.fs +++ b/tests/Paket.Tests/ProjectFile/FileBuildActionSpecs.fs @@ -14,14 +14,12 @@ let createProject name = [] let ``should recognize compilable files``() = - - (createProject "A.csproj").DetermineBuildAction "Class.cs" |> shouldEqual "Compile" - (createProject "B.fsproj").DetermineBuildAction "Module.fs" |> shouldEqual "Compile" - (createProject "C.vbproj").DetermineBuildAction "Whatever.vb" |> shouldEqual "Compile" + (createProject "A.csproj").DetermineBuildAction "Class.cs" |> shouldEqual BuildAction.Compile + (createProject "B.fsproj").DetermineBuildAction "Module.fs" |> shouldEqual BuildAction.Compile + (createProject "C.vbproj").DetermineBuildAction "Whatever.vb" |> shouldEqual BuildAction.Compile [] let ``should recognize content files``() = - - (createProject "A.csproj").DetermineBuildAction "Something.js" |> shouldEqual "Content" - (createProject "B.fsproj").DetermineBuildAction "config.yml" |> shouldEqual "Content" - (createProject "C.vbproj").DetermineBuildAction "noext" |> shouldEqual "Content" \ No newline at end of file + (createProject "A.csproj").DetermineBuildAction "Something.js" |> shouldEqual BuildAction.Content + (createProject "B.fsproj").DetermineBuildAction "config.yml" |> shouldEqual BuildAction.Content + (createProject "C.vbproj").DetermineBuildAction "noext" |> shouldEqual BuildAction.Content \ No newline at end of file diff --git a/tests/Paket.Tests/ProjectFile/OutputSpecs.fs b/tests/Paket.Tests/ProjectFile/OutputSpecs.fs index 5fbcecc82d..3d0d44a247 100644 --- a/tests/Paket.Tests/ProjectFile/OutputSpecs.fs +++ b/tests/Paket.Tests/ProjectFile/OutputSpecs.fs @@ -63,29 +63,29 @@ let ``should maintain order when updating project file items`` () = let projFile = ProjectFile.TryLoad("./ProjectFile/TestData/MaintainsOrdering.fsprojtest").Value let fileItems = [ - { BuildAction = "Compile"; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\Pluralizer.fs"; Link = Some("fsharp_data\\Pluralizer.fs") } - { BuildAction = "Compile"; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\NameUtils.fs"; Link = Some("fsharp_data\\NameUtils.fs") } - { BuildAction = "Compile"; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\TextConversions.fs"; Link = Some("fsharp_data\\TextConversions.fs") } - { BuildAction = "Compile"; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\StructuralTypes.fs"; Link = Some("fsharp_data\\StructuralTypes.fs") } - { BuildAction = "Compile"; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\StructuralInference.fs"; Link = Some("fsharp_data\\StructuralInference.fs") } - { BuildAction = "Compile"; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\TextRuntime.fs"; Link = Some("fsharp_data\\TextRuntime.fs") } - { BuildAction = "Compile"; Include = "DebugProvidedTypes.fs"; Link = None } - { BuildAction = "Compile"; Include = "ProvidedTypes.fs"; Link = None } - { BuildAction = "Content"; Include = "ProvidedTypes.fsi"; Link = None } + { BuildAction = BuildAction.Compile; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\Pluralizer.fs"; Link = Some("fsharp_data\\Pluralizer.fs") } + { BuildAction = BuildAction.Compile; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\NameUtils.fs"; Link = Some("fsharp_data\\NameUtils.fs") } + { BuildAction = BuildAction.Compile; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\TextConversions.fs"; Link = Some("fsharp_data\\TextConversions.fs") } + { BuildAction = BuildAction.Compile; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\StructuralTypes.fs"; Link = Some("fsharp_data\\StructuralTypes.fs") } + { BuildAction = BuildAction.Compile; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\StructuralInference.fs"; Link = Some("fsharp_data\\StructuralInference.fs") } + { BuildAction = BuildAction.Compile; Include = "..\\..\\paket-files\\fsharp\\FSharp.Data\\src\\CommonRuntime\\TextRuntime.fs"; Link = Some("fsharp_data\\TextRuntime.fs") } + { BuildAction = BuildAction.Compile; Include = "DebugProvidedTypes.fs"; Link = None } + { BuildAction = BuildAction.Compile; Include = "ProvidedTypes.fs"; Link = None } + { BuildAction = BuildAction.Content; Include = "ProvidedTypes.fsi"; Link = None } ] projFile.UpdateFileItems(fileItems, false) let rec nodes node = seq { for node in node |> Seq.cast do - if node.Name = "Compile" || node.Name = "Content" + if node.Name ="Compile" || node.Name = "Content" then yield Paket.Xml.getAttribute "Include" node yield! nodes node } let actual = - nodes projFile.Document - |> Seq.choose id + nodes projFile.Document + |> Seq.choose id |> Seq.toList let expected = [ @@ -111,23 +111,23 @@ let ``should remove missing files that exist in the project`` () = let projFile = ProjectFile.TryLoad("./ProjectFile/TestData/MaintainsOrdering.fsprojtest").Value let fileItems = [ - { BuildAction = "Compile"; Include = "DebugProvidedTypes.fs"; Link = None } - { BuildAction = "Compile"; Include = "ProvidedTypes.fs"; Link = None } - { BuildAction = "Content"; Include = "ProvidedTypes.fsi"; Link = None } + { BuildAction = BuildAction.Compile; Include = "DebugProvidedTypes.fs"; Link = None } + { BuildAction = BuildAction.Compile; Include = "ProvidedTypes.fs"; Link = None } + { BuildAction = BuildAction.Content; Include = "ProvidedTypes.fsi"; Link = None } ] projFile.UpdateFileItems(fileItems, false) let rec nodes node = seq { for node in node |> Seq.cast do - if node.Name = "Compile" || node.Name = "Content" + if node.Name ="Compile" || node.Name = "Content" then yield Paket.Xml.getAttribute "Include" node yield! nodes node } let actual = - nodes projFile.Document - |> Seq.choose id + nodes projFile.Document + |> Seq.choose id |> Seq.toList let expected = [ From e7f463617384db78b032effab92af08fa2655016 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 5 Jan 2016 15:52:17 +0100 Subject: [PATCH 2/3] Show warning when paket.references is used in nupkg content - fixes #1344 --- RELEASE_NOTES.md | 3 +++ src/Paket.Core/InstallProcess.fs | 12 +++++++----- src/Paket.Core/UpdateProcess.fs | 4 ++-- src/Paket/Paket.fsproj | 4 ++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 2c772ee21d..9f358e0477 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 2.40.5 - 05.01.2016 +* USABILITY: Show warning when paket.references is used in nupkg content - https://github.com/fsprojects/Paket/issues/1344 + #### 2.40.4 - 03.01.2016 * USABILITY: Report group name in download trace - https://github.com/fsprojects/Paket/issues/1337 diff --git a/src/Paket.Core/InstallProcess.fs b/src/Paket.Core/InstallProcess.fs index 5b8c088a5e..978b3a9dac 100644 --- a/src/Paket.Core/InstallProcess.fs +++ b/src/Paket.Core/InstallProcess.fs @@ -79,7 +79,9 @@ let processContentFiles root project (usedPackages:Map<_,_>) gitRemoteItems opti |> List.append (fromDir.GetFiles() |> Array.toList - |> List.filter (onBlackList >> not) + |> List.filter (fun file -> + if onBlackList file then false else + if file.Name = "paket.references" then traceWarnfn "You can't use paket.references as a content file in the root of a project. Please take a look at %s" file.FullName; false else true) |> List.map (fun file -> let overwrite = settings = ContentCopySettings.Overwrite let target = FileInfo(Path.Combine(toDir.Force().FullName, file.Name)) @@ -119,7 +121,7 @@ let processContentFiles root project (usedPackages:Map<_,_>) gitRemoteItems opti removeEmptyDirHierarchy (DirectoryInfo dirPath) project.GetPaketFileItems() - |> List.filter (fun fi -> not <| fi.FullName.Contains(Constants.PaketFilesFolderName) && not (contentFiles.Contains(fi.FullName))) + |> List.filter (fun fi -> not <| fi.FullName.Contains(Constants.PaketFilesFolderName) && not (contentFiles.Contains(fi.FullName)) && fi.Name <> "paket.references") |> removeFilesAndTrimDirs removeCopiedFiles project @@ -264,10 +266,10 @@ let findAllReferencesFiles root = |> collect /// Installs all packages from the lock file. -let InstallIntoProjects(options : InstallerOptions, dependenciesFile, lockFile : LockFile, projects : (ProjectFile * ReferencesFile) list) = +let InstallIntoProjects(options : InstallerOptions, dependenciesFile, lockFile : LockFile, projectsAndReferences : (ProjectFile * ReferencesFile) list) = let packagesToInstall = if options.OnlyReferenced then - projects + projectsAndReferences |> List.map (fun (_, referencesFile)-> referencesFile |> lockFile.GetPackageHull @@ -281,7 +283,7 @@ let InstallIntoProjects(options : InstallerOptions, dependenciesFile, lockFile : let model = CreateModel(root, options.Force, dependenciesFile, lockFile, Set.ofSeq packagesToInstall) |> Map.ofArray let lookup = lockFile.GetDependencyLookupTable() - for project : ProjectFile, referenceFile in projects do + for project, referenceFile in projectsAndReferences do verbosefn "Installing to %s" project.FileName let usedPackages = diff --git a/src/Paket.Core/UpdateProcess.fs b/src/Paket.Core/UpdateProcess.fs index fcf7892ac6..a33fccb61f 100644 --- a/src/Paket.Core/UpdateProcess.fs +++ b/src/Paket.Core/UpdateProcess.fs @@ -193,10 +193,10 @@ let SmartInstall(dependenciesFile, updateMode, options : UpdaterOptions) = let lockFile = SelectiveUpdate(dependenciesFile, updateMode, options.Common.SemVerUpdateMode, options.Common.Force) let root = Path.GetDirectoryName dependenciesFile.FileName - let projects = InstallProcess.findAllReferencesFiles root |> returnOrFail + let projectsAndReferences = InstallProcess.findAllReferencesFiles root |> returnOrFail if not options.NoInstall then - InstallProcess.InstallIntoProjects(options.Common, dependenciesFile, lockFile, projects) + InstallProcess.InstallIntoProjects(options.Common, dependenciesFile, lockFile, projectsAndReferences) /// Update a single package command let UpdatePackage(dependenciesFileName, groupName, packageName : PackageName, newVersion, options : UpdaterOptions) = diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index 428141f7f8..241fdaabb1 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -38,7 +38,7 @@ pack output D:\code\paketbug\output install restore - update -f + install Project paket.exe c:\code\Paketkopie @@ -48,7 +48,7 @@ d:\code\paketrepro D:\code\Paket\integrationtests\scenarios\i001270-net461\temp C:\code\restore - D:\code\FSharpVSPowerTools\ + D:\code\ConsoleApplication8 pdbonly From 2e6dd010c6521ed20c34b3268ecab9c0f6ff87b1 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Tue, 5 Jan 2016 16:23:29 +0100 Subject: [PATCH 3/3] Bump version to 2.40.5 --- src/Paket.Bootstrapper/Properties/AssemblyInfo.cs | 8 ++++---- src/Paket.Core/AssemblyInfo.fs | 8 ++++---- src/Paket.PowerShell/AssemblyInfo.fs | 8 ++++---- src/Paket/AssemblyInfo.fs | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs b/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs index 138db7fa7d..405e3c3032 100644 --- a/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs +++ b/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs @@ -4,11 +4,11 @@ [assembly: AssemblyTitleAttribute("Paket.Bootstrapper")] [assembly: AssemblyProductAttribute("Paket")] [assembly: AssemblyDescriptionAttribute("A package dependency manager for .NET with support for NuGet packages and GitHub repositories.")] -[assembly: AssemblyVersionAttribute("2.40.4")] -[assembly: AssemblyFileVersionAttribute("2.40.4")] -[assembly: AssemblyInformationalVersionAttribute("2.40.4")] +[assembly: AssemblyVersionAttribute("2.40.5")] +[assembly: AssemblyFileVersionAttribute("2.40.5")] +[assembly: AssemblyInformationalVersionAttribute("2.40.5")] namespace System { internal static class AssemblyVersionInformation { - internal const string Version = "2.40.4"; + internal const string Version = "2.40.5"; } } diff --git a/src/Paket.Core/AssemblyInfo.fs b/src/Paket.Core/AssemblyInfo.fs index a85197907d..b1014dfdb7 100644 --- a/src/Paket.Core/AssemblyInfo.fs +++ b/src/Paket.Core/AssemblyInfo.fs @@ -5,10 +5,10 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "2.40.4" + let [] Version = "2.40.5" diff --git a/src/Paket.PowerShell/AssemblyInfo.fs b/src/Paket.PowerShell/AssemblyInfo.fs index bd3122aaed..bd63a35c56 100644 --- a/src/Paket.PowerShell/AssemblyInfo.fs +++ b/src/Paket.PowerShell/AssemblyInfo.fs @@ -5,10 +5,10 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "2.40.4" + let [] Version = "2.40.5" diff --git a/src/Paket/AssemblyInfo.fs b/src/Paket/AssemblyInfo.fs index 7c844d58c5..31c42ff184 100644 --- a/src/Paket/AssemblyInfo.fs +++ b/src/Paket/AssemblyInfo.fs @@ -5,10 +5,10 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "2.40.4" + let [] Version = "2.40.5"