Skip to content

Commit

Permalink
Paket fails on dependencies file that has same package twice in same …
Browse files Browse the repository at this point in the history
…group - fixes #1757
  • Loading branch information
forki committed Jun 25, 2016
1 parent c7f23ab commit 23b5485
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 58 deletions.
9 changes: 3 additions & 6 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/Paket.Bootstrapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
10 changes: 5 additions & 5 deletions src/Paket.Core/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<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")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "3.2.3"
let [<Literal>] InformationalVersion = "3.2.3"
let [<Literal>] Version = "3.3.0"
let [<Literal>] InformationalVersion = "3.3.0"
16 changes: 8 additions & 8 deletions src/Paket.Core/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, 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
Expand Down Expand Up @@ -333,7 +333,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
DependenciesFile(
list
|> Seq.toArray
|> DependenciesFileParser.parseDependenciesFile fileName)
|> DependenciesFileParser.parseDependenciesFile fileName false)


member this.AddAdditionalPackage(groupName, packageName:PackageName,version:string,settings) =
Expand Down Expand Up @@ -374,7 +374,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr

let fileName, groups, lines =
removeElementAt pos textRepresentation
|> DependenciesFileParser.parseDependenciesFile fileName
|> DependenciesFileParser.parseDependenciesFile fileName false

let filteredGroups, filteredLines =
groups
Expand Down Expand Up @@ -423,7 +423,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, 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
Expand All @@ -442,7 +442,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, 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

Expand All @@ -453,14 +453,14 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, 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) =
Expand Down
14 changes: 8 additions & 6 deletions src/Paket.Core/DependenciesFileParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/NugetConvert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
10 changes: 5 additions & 5 deletions src/Paket.PowerShell/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<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")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "3.2.3"
let [<Literal>] InformationalVersion = "3.2.3"
let [<Literal>] Version = "3.3.0"
let [<Literal>] InformationalVersion = "3.3.0"
10 changes: 5 additions & 5 deletions src/Paket/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<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")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "3.2.3"
let [<Literal>] InformationalVersion = "3.2.3"
let [<Literal>] Version = "3.3.0"
let [<Literal>] InformationalVersion = "3.3.0"
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<StartArguments>update -f</StartArguments>
<StartWorkingDirectory>D:\code\Paket\integrationtests\scenarios\i001117-aws\temp</StartWorkingDirectory>
<StartArguments>restore</StartArguments>
<StartWorkingDirectory>D:\code\fixieSpec</StartWorkingDirectory>
<StartWorkingDirectory>D:\temp\paket</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
Expand Down
16 changes: 8 additions & 8 deletions tests/Paket.Tests/DependenciesFile/AddPackageSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
17 changes: 16 additions & 1 deletion tests/Paket.Tests/DependenciesFile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
(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
"""

[<Test>]
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" -> ()
12 changes: 6 additions & 6 deletions tests/Paket.Tests/DependenciesFile/SaveSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

[<Test>]
let ``should serialize config with password``() =
Expand All @@ -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"""

[<Test>]
let ``should serialize config with envrionment variable password``() =
Expand Down

0 comments on commit 23b5485

Please sign in to comment.