From 23b5485c81eb5430f6093df6e03062cf0b38c871 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sat, 25 Jun 2016 16:04:30 +0200 Subject: [PATCH] Paket fails on dependencies file that has same package twice in same group - fixes #1757 --- RELEASE_NOTES.md | 9 +++------ .../i001534-selenium/before/paket.dependencies | 1 - .../Properties/AssemblyInfo.cs | 10 +++++----- src/Paket.Core/AssemblyInfo.fs | 10 +++++----- src/Paket.Core/DependenciesFile.fs | 16 ++++++++-------- src/Paket.Core/DependenciesFileParser.fs | 14 ++++++++------ src/Paket.Core/NugetConvert.fs | 2 +- src/Paket.PowerShell/AssemblyInfo.fs | 10 +++++----- src/Paket/AssemblyInfo.fs | 10 +++++----- src/Paket/Paket.fsproj | 2 +- .../DependenciesFile/AddPackageSpecs.fs | 16 ++++++++-------- .../Paket.Tests/DependenciesFile/ParserSpecs.fs | 17 ++++++++++++++++- tests/Paket.Tests/DependenciesFile/SaveSpecs.fs | 12 ++++++------ 13 files changed, 71 insertions(+), 58 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d0145a8142..7741be437f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,12 +1,9 @@ -#### 3.2.3 - 25.06.2016 +#### 3.3.0 - 25.06.2016 +* Paket fails on dependencies file that has same package twice in same group - https://github.com/fsprojects/Paket/issues/1757 +* Paket.SemVer.Parse is now in PublicAPI.fs - https://github.com/fsprojects/Paket/pull/1754 * BUGFIX: Automatic repair of broken file paths in NuGet packages - https://github.com/fsprojects/Paket/issues/1755 - -#### 3.2.2 - 24.06.2016 * BUGFIX: Fixed out-of-date check for auto-detection of frameworks - https://github.com/fsprojects/Paket/issues/1750 -#### 3.2.1 - 24.06.2016 -* Paket.SemVer.Parse is now in PublicAPI.fs - https://github.com/fsprojects/Paket/pull/1754 - #### 3.2.0 - 24.06.2016 * Show out-of-sync error message if paket.lock is not matching paket.dependencies - https://github.com/fsprojects/Paket/issues/1750 * BUGFIX: Dependency resolution for .NETFramework4.5 and .NETPortable0.0-wp8+netcore45+net45+wp81+wpa81 fixed - https://github.com/fsprojects/Paket/issues/1753 diff --git a/integrationtests/scenarios/i001534-selenium/before/paket.dependencies b/integrationtests/scenarios/i001534-selenium/before/paket.dependencies index 3d8300e704..d14a273133 100644 --- a/integrationtests/scenarios/i001534-selenium/before/paket.dependencies +++ b/integrationtests/scenarios/i001534-selenium/before/paket.dependencies @@ -8,7 +8,6 @@ nuget FubuMVC.RavenDb 3.0.0.2189-alpha -pre nuget FubuMVC.LightningQueues 3.0.0.2189-alpha -pre nuget GhostScriptSharp == 1.3.1.4 nuget log4net 1.2.10.0 -nuget Newtonsoft.Json == 4.5.9 nuget NLog == 3.1.0.0 nuget NUnit == 2.6.3.0 nuget NUnit.Runners == 2.6.3.0 diff --git a/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs b/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs index 31b0794ea0..bd449fdbc5 100644 --- a/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs +++ b/src/Paket.Bootstrapper/Properties/AssemblyInfo.cs @@ -4,12 +4,12 @@ [assembly: AssemblyTitleAttribute("Paket.Bootstrapper")] [assembly: AssemblyProductAttribute("Paket")] [assembly: AssemblyDescriptionAttribute("A dependency manager for .NET with support for NuGet packages and git repositories.")] -[assembly: AssemblyVersionAttribute("3.2.3")] -[assembly: AssemblyFileVersionAttribute("3.2.3")] -[assembly: AssemblyInformationalVersionAttribute("3.2.3")] +[assembly: AssemblyVersionAttribute("3.3.0")] +[assembly: AssemblyFileVersionAttribute("3.3.0")] +[assembly: AssemblyInformationalVersionAttribute("3.3.0")] namespace System { internal static class AssemblyVersionInformation { - internal const string Version = "3.2.3"; - internal const string InformationalVersion = "3.2.3"; + internal const string Version = "3.3.0"; + internal const string InformationalVersion = "3.3.0"; } } diff --git a/src/Paket.Core/AssemblyInfo.fs b/src/Paket.Core/AssemblyInfo.fs index bf75f65c31..8e3a39fe59 100644 --- a/src/Paket.Core/AssemblyInfo.fs +++ b/src/Paket.Core/AssemblyInfo.fs @@ -5,11 +5,11 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "3.2.3" - let [] InformationalVersion = "3.2.3" + let [] Version = "3.3.0" + let [] InformationalVersion = "3.3.0" diff --git a/src/Paket.Core/DependenciesFile.fs b/src/Paket.Core/DependenciesFile.fs index dae8155963..0dcc1ed480 100644 --- a/src/Paket.Core/DependenciesFile.fs +++ b/src/Paket.Core/DependenciesFile.fs @@ -233,7 +233,7 @@ type DependenciesFile(fileName,groups:Map, textRepr DependenciesFile( list |> Seq.toArray - |> DependenciesFileParser.parseDependenciesFile fileName) + |> DependenciesFileParser.parseDependenciesFile fileName false) member __.AddAdditionalPackage(groupName, packageName:PackageName,versionRequirement,resolverStrategy,settings,?pinDown) = let pinDown = defaultArg pinDown false @@ -333,7 +333,7 @@ type DependenciesFile(fileName,groups:Map, textRepr DependenciesFile( list |> Seq.toArray - |> DependenciesFileParser.parseDependenciesFile fileName) + |> DependenciesFileParser.parseDependenciesFile fileName false) member this.AddAdditionalPackage(groupName, packageName:PackageName,version:string,settings) = @@ -374,7 +374,7 @@ type DependenciesFile(fileName,groups:Map, textRepr let fileName, groups, lines = removeElementAt pos textRepresentation - |> DependenciesFileParser.parseDependenciesFile fileName + |> DependenciesFileParser.parseDependenciesFile fileName false let filteredGroups, filteredLines = groups @@ -423,7 +423,7 @@ type DependenciesFile(fileName,groups:Map, textRepr DependenciesFileSerializer.packageString packageName vr.VersionRequirement vr.ResolverStrategy p.Settings else l) - DependenciesFile(DependenciesFileParser.parseDependenciesFile this.FileName newLines) + DependenciesFile(DependenciesFileParser.parseDependenciesFile this.FileName false newLines) else traceWarnfn "%s doesn't contain package %O in group %O. ==> Ignored" fileName packageName groupName this @@ -442,7 +442,7 @@ type DependenciesFile(fileName,groups:Map, textRepr DependenciesFileSerializer.packageString matchedPackageName vr.VersionRequirement vr.ResolverStrategy p.Settings | None -> l) - DependenciesFile(DependenciesFileParser.parseDependenciesFile this.FileName newLines) + DependenciesFile(DependenciesFileParser.parseDependenciesFile this.FileName false newLines) member this.RootPath = FileInfo(fileName).Directory.FullName @@ -453,14 +453,14 @@ type DependenciesFile(fileName,groups:Map, textRepr tracefn "Dependencies files saved to %s" fileName static member FromCode(rootPath,code:string) : DependenciesFile = - DependenciesFile(DependenciesFileParser.parseDependenciesFile (Path.Combine(rootPath,Constants.DependenciesFileName)) <| code.Replace("\r\n","\n").Replace("\r","\n").Split('\n')) + DependenciesFile(DependenciesFileParser.parseDependenciesFile (Path.Combine(rootPath,Constants.DependenciesFileName)) true <| code.Replace("\r\n","\n").Replace("\r","\n").Split('\n')) static member FromCode(code:string) : DependenciesFile = - DependenciesFile(DependenciesFileParser.parseDependenciesFile "" <| code.Replace("\r\n","\n").Replace("\r","\n").Split('\n')) + DependenciesFile(DependenciesFileParser.parseDependenciesFile "" true <| code.Replace("\r\n","\n").Replace("\r","\n").Split('\n')) static member ReadFromFile fileName : DependenciesFile = verbosefn "Parsing %s" fileName - DependenciesFile(DependenciesFileParser.parseDependenciesFile fileName <| File.ReadAllLines fileName) + DependenciesFile(DependenciesFileParser.parseDependenciesFile fileName true <| File.ReadAllLines fileName) /// Find the matching lock file to a dependencies file static member FindLockfile(dependenciesFileName) = diff --git a/src/Paket.Core/DependenciesFileParser.fs b/src/Paket.Core/DependenciesFileParser.fs index 0a762184c7..5151805b82 100644 --- a/src/Paket.Core/DependenciesFileParser.fs +++ b/src/Paket.Core/DependenciesFileParser.fs @@ -366,7 +366,7 @@ module DependenciesFileParser = | OmitContent omit -> { current.Options with Settings = { current.Options.Settings with OmitContent = Some omit } } | ReferenceCondition condition -> { current.Options with Settings = { current.Options.Settings with ReferenceCondition = Some condition } } - let private parseLine fileName (lineNo, state) line = + let private parseLine fileName checkDuplicates (lineNo, state) line = match state with | current::other -> let lineNo = lineNo + 1 @@ -382,9 +382,11 @@ module DependenciesFileParser = | ParserOptions(options) -> lineNo,{ current with Options = parseOptions current options} ::other | Package(name,version,rest) -> - let package = parsePackage(current.Sources,DependenciesFile fileName,name,version,rest) - - lineNo, { current with Packages = current.Packages @ [package] }::other + let package = parsePackage(current.Sources,DependenciesFile fileName,name,version,rest) + if checkDuplicates && current.Packages |> List.exists (fun p -> p.Name = package.Name) then + failwithf "Package %O is defined more than once in group %O of %s" package.Name current.Name fileName + + lineNo, { current with Packages = current.Packages @ [package] }::other | SourceFile(origin, (owner,project, vr), path, authKey) -> let remoteFile : UnresolvedSource = { Owner = owner @@ -433,10 +435,10 @@ module DependenciesFileParser = | exn -> failwithf "Error in paket.dependencies line %d%s %s" lineNo Environment.NewLine exn.Message | [] -> failwithf "Error in paket.dependencies line %d" lineNo - let parseDependenciesFile fileName lines = + let parseDependenciesFile fileName checkDuplicates lines = let groups = lines - |> Array.fold (parseLine fileName) (0, [DependenciesGroup.New Constants.MainDependencyGroup]) + |> Array.fold (parseLine fileName checkDuplicates) (0, [DependenciesGroup.New Constants.MainDependencyGroup]) |> snd |> List.rev |> List.fold (fun m g -> diff --git a/src/Paket.Core/NugetConvert.fs b/src/Paket.Core/NugetConvert.fs index 6fd6cecb81..21b0c235b9 100644 --- a/src/Paket.Core/NugetConvert.fs +++ b/src/Paket.Core/NugetConvert.fs @@ -298,7 +298,7 @@ let createDependenciesFileR (rootDirectory : DirectoryInfo) nugetEnv mode = let newLines = sourceLines @ [""] @ packageLines |> Seq.toArray - Paket.DependenciesFile(DependenciesFileParser.parseDependenciesFile dependenciesFileName newLines)) + Paket.DependenciesFile(DependenciesFileParser.parseDependenciesFile dependenciesFileName false newLines)) if File.Exists dependenciesFileName then read() else create() |> lift (fun d -> d.SimplifyFrameworkRestrictions()) diff --git a/src/Paket.PowerShell/AssemblyInfo.fs b/src/Paket.PowerShell/AssemblyInfo.fs index adae226bbd..18729aa61b 100644 --- a/src/Paket.PowerShell/AssemblyInfo.fs +++ b/src/Paket.PowerShell/AssemblyInfo.fs @@ -5,11 +5,11 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "3.2.3" - let [] InformationalVersion = "3.2.3" + let [] Version = "3.3.0" + let [] InformationalVersion = "3.3.0" diff --git a/src/Paket/AssemblyInfo.fs b/src/Paket/AssemblyInfo.fs index b295a56b17..155c21b0d4 100644 --- a/src/Paket/AssemblyInfo.fs +++ b/src/Paket/AssemblyInfo.fs @@ -5,11 +5,11 @@ open System.Reflection [] [] [] -[] -[] -[] +[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "3.2.3" - let [] InformationalVersion = "3.2.3" + let [] Version = "3.3.0" + let [] InformationalVersion = "3.3.0" diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index df5b6ca79e..44334e0e2b 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -52,7 +52,7 @@ update -f D:\code\Paket\integrationtests\scenarios\i001117-aws\temp restore - D:\code\fixieSpec + D:\temp\paket 11 diff --git a/tests/Paket.Tests/DependenciesFile/AddPackageSpecs.fs b/tests/Paket.Tests/DependenciesFile/AddPackageSpecs.fs index ccdc0b3e15..7e8980ef77 100644 --- a/tests/Paket.Tests/DependenciesFile/AddPackageSpecs.fs +++ b/tests/Paket.Tests/DependenciesFile/AddPackageSpecs.fs @@ -256,7 +256,7 @@ let ``should add Microsoft.AspNet.WebApi package in correct position if package nuget Microsoft.AspNet.WebApi.Client 5.2.3 nuget Microsoft.AspNet.WebApi.Core 5.2.3 nuget Microsoft.AspNet.WebApi.WebHost 5.2.3 -nuget log4net +nuget log3net source https://www.nuget.org/api/v2 nuget Microsoft.AspNet.WebApi @@ -269,7 +269,7 @@ nuget log4net 1.2.10""" nuget Microsoft.AspNet.WebApi.Client 5.2.3 nuget Microsoft.AspNet.WebApi.Core 5.2.3 nuget Microsoft.AspNet.WebApi.WebHost 5.2.3 -nuget log4net +nuget log3net source https://www.nuget.org/api/v2 nuget Microsoft.AspNet.WebApi 5.2.3 @@ -284,7 +284,7 @@ let ``should pin Microsoft.AspNet.WebApi.Client package in correct position``() nuget Microsoft.AspNet.WebApi.Core 5.2.3 nuget Microsoft.AspNet.WebApi.WebHost 5.2.3 -nuget log4net +nuget log3net source https://www.nuget.org/api/v2 nuget Microsoft.AspNet.WebApi @@ -296,7 +296,7 @@ nuget log4net 1.2.10""" nuget Microsoft.AspNet.WebApi.Core 5.2.3 nuget Microsoft.AspNet.WebApi.WebHost 5.2.3 -nuget log4net +nuget log3net source https://www.nuget.org/api/v2 nuget Microsoft.AspNet.WebApi @@ -314,7 +314,7 @@ let ``should add Microsoft.AspNet.WebApi package in correct position if package nuget Microsoft.AspNet.WebApi.Client 5.2.3 nuget Microsoft.AspNet.WebApi.Core 5.2.3 nuget Microsoft.AspNet.WebApi.WebHost 5.2.3 -nuget log4net +nuget log3net source https://www.nuget.org/api/v2 nuget Microsoft.AspNet.WebApi 5.2.1 @@ -327,7 +327,7 @@ nuget log4net 1.2.10""" nuget Microsoft.AspNet.WebApi.Client 5.2.3 nuget Microsoft.AspNet.WebApi.Core 5.2.3 nuget Microsoft.AspNet.WebApi.WebHost 5.2.3 -nuget log4net +nuget log3net source https://www.nuget.org/api/v2 nuget Microsoft.AspNet.WebApi 5.2.1 @@ -354,7 +354,7 @@ nuget Microsoft.AspNet.WebApi 1.0.071.9432""" let ``should add Moq to second feed``() = let config = """source http://internalfeed/NugetWebFeed/nuget -nuget log4net +nuget log3net nuget Microsoft.AspNet.WebApi.Client 5.2.3 nuget Microsoft.AspNet.WebApi.Core 5.2.3 nuget Microsoft.AspNet.WebApi.WebHost 5.2.3 @@ -368,7 +368,7 @@ nuget Microsoft.AspNet.WebApi 5.2.1 let expected = """source http://internalfeed/NugetWebFeed/nuget -nuget log4net +nuget log3net nuget Microsoft.AspNet.WebApi.Client 5.2.3 nuget Microsoft.AspNet.WebApi.Core 5.2.3 nuget Microsoft.AspNet.WebApi.WebHost 5.2.3 diff --git a/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs b/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs index 9210a99903..82841d981b 100644 --- a/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs +++ b/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs @@ -1327,4 +1327,19 @@ let ``should read config with caches``() = (main.Sources |> List.item 0) |> shouldEqual PackageSources.DefaultNuGetSource (main.Sources |> List.item 1).Url |> shouldEqual "./dependencies" - (main.Sources |> List.item 2).Url |> shouldEqual "//hive/dependencies" \ No newline at end of file + (main.Sources |> List.item 2).Url |> shouldEqual "//hive/dependencies" + +let duplicateNuget = """ +source https://www.nuget.org/api/v2/ + +nuget NuGet.CommandLine +nuget NuGet.CommandLine framework: portable45-net45+win8 +""" + +[] +let ``should fail on config with duplicate NuGet packahe``() = + try + DependenciesFile.FromCode(duplicateNuget) |> ignore + failwith "expected error" + with + | exn when exn.Message.Contains "NuGet.CommandLine" -> () \ No newline at end of file diff --git a/tests/Paket.Tests/DependenciesFile/SaveSpecs.fs b/tests/Paket.Tests/DependenciesFile/SaveSpecs.fs index daaead4dba..741b1a9c45 100644 --- a/tests/Paket.Tests/DependenciesFile/SaveSpecs.fs +++ b/tests/Paket.Tests/DependenciesFile/SaveSpecs.fs @@ -141,9 +141,9 @@ let configWithPassword = """source http://www.nuget.org/api/v2 username: "user" nuget Example > 1.2.3 nuget Example2 <= 1.2.3 nuget Example3 < 2.2.3 -nuget Example3 == 2.2.3 -nuget Example3 !== 2.2.3 -nuget Example4 >= 1.2.3 < 1.5""" +nuget Example4 == 2.2.3 +nuget Example5 !== 2.2.3 +nuget Example6 >= 1.2.3 < 1.5""" [] let ``should serialize config with password``() = @@ -158,9 +158,9 @@ let configWithEnvVarPassword = """source http://www.nuget.org/api/v2 username: " nuget Example > 1.2.3 nuget Example2 <= 1.2.3 nuget Example3 < 2.2.3 -nuget Example3 == 2.2.3 -nuget Example3 !== 2.2.3 -nuget Example4 >= 1.2.3 < 1.5""" +nuget Example4 == 2.2.3 +nuget Example5 !== 2.2.3 +nuget Example6 >= 1.2.3 < 1.5""" [] let ``should serialize config with envrionment variable password``() =