From d54c784a861cc2da28efa118f49178ffbc4cacf7 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Fri, 27 Nov 2015 14:17:52 +0100 Subject: [PATCH] Better error message when lock file doesn't contain version pin - fix #1256 --- RELEASE_NOTES.md | 3 +++ .../Paket.IntegrationTests/InstallSpecs.fs | 10 +++++++++- .../i001256-wrong-lock/before/paket.dependencies | 3 +++ .../scenarios/i001256-wrong-lock/before/paket.lock | 4 ++++ src/Paket.Core/LockFile.fs | 5 ++++- 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 integrationtests/scenarios/i001256-wrong-lock/before/paket.dependencies create mode 100644 integrationtests/scenarios/i001256-wrong-lock/before/paket.lock diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7326ac37ce..6936afab48 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 2.28.1 - 27.11.2015 +* Better error message when lock file doesn't contain version pin - https://github.com/fsprojects/Paket/issues/1256 + #### 2.28.1 - 27.11.2015 * Do not normalize versions since it might break Klondike - https://github.com/fsprojects/Paket/issues/1257 diff --git a/integrationtests/Paket.IntegrationTests/InstallSpecs.fs b/integrationtests/Paket.IntegrationTests/InstallSpecs.fs index b2f78623c0..fa49048a14 100644 --- a/integrationtests/Paket.IntegrationTests/InstallSpecs.fs +++ b/integrationtests/Paket.IntegrationTests/InstallSpecs.fs @@ -44,4 +44,12 @@ let ``#1233 install props``() = let oldFile = Path.Combine(originalScenarioPath "i001233-props-files","MyClassLibrary","MyClassLibrary","MyClassLibrary.csprojtemplate") let s1 = File.ReadAllText oldFile |> normalizeLineEndings let s2 = File.ReadAllText newFile |> normalizeLineEndings - s1 |> shouldEqual s2 \ No newline at end of file + s1 |> shouldEqual s2 + +[] +let ``#1256 should report error in lock file``() = + try + install "i001256-wrong-lock" |> ignore + failwith "error expected" + with + | exn when exn.Message.Contains("FAKE") && exn.Message.Contains("paket.lock") -> () \ No newline at end of file diff --git a/integrationtests/scenarios/i001256-wrong-lock/before/paket.dependencies b/integrationtests/scenarios/i001256-wrong-lock/before/paket.dependencies new file mode 100644 index 0000000000..106f74ae30 --- /dev/null +++ b/integrationtests/scenarios/i001256-wrong-lock/before/paket.dependencies @@ -0,0 +1,3 @@ +source https://nuget.org/api/v2 + +nuget FAKE \ No newline at end of file diff --git a/integrationtests/scenarios/i001256-wrong-lock/before/paket.lock b/integrationtests/scenarios/i001256-wrong-lock/before/paket.lock new file mode 100644 index 0000000000..993cdca423 --- /dev/null +++ b/integrationtests/scenarios/i001256-wrong-lock/before/paket.lock @@ -0,0 +1,4 @@ +NUGET + remote: https://nuget.org/api/v2 + specs: + FAKE \ No newline at end of file diff --git a/src/Paket.Core/LockFile.fs b/src/Paket.Core/LockFile.fs index 4bc104ce23..f423264425 100644 --- a/src/Paket.Core/LockFile.fs +++ b/src/Paket.Core/LockFile.fs @@ -264,7 +264,10 @@ module LockFileParser = | Some remote -> let package,settings = parsePackage details let parts' = package.Split ' ' - let version = parts'.[1] |> removeBrackets + let version = + if parts'.Length < 2 then + failwithf "No version specified for package %O in group %O." package currentGroup.GroupName + parts'.[1] |> removeBrackets { currentGroup with LastWasPackage = true