Skip to content

Commit

Permalink
Improve error messages for dependency groups - closes #1797
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 12, 2016
1 parent a12892f commit 8e45f69
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 31 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#### 3.6.0 - 12.07.2016
* Generate include script for each group - https://github.com/fsprojects/Paket/pull/1787
* USABILITY: Improve error messages for dependency groups - https://github.com/fsprojects/Paket/pull/1797

#### 3.5.0 - 12.07.2016
* Support for .NET 4.6.3 and .NET Standard 1.6
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.5.0")]
[assembly: AssemblyFileVersionAttribute("3.5.0")]
[assembly: AssemblyInformationalVersionAttribute("3.5.0")]
[assembly: AssemblyVersionAttribute("3.6.0")]
[assembly: AssemblyFileVersionAttribute("3.6.0")]
[assembly: AssemblyInformationalVersionAttribute("3.6.0")]
namespace System {
internal static class AssemblyVersionInformation {
internal const string Version = "3.5.0";
internal const string InformationalVersion = "3.5.0";
internal const string Version = "3.6.0";
internal const string InformationalVersion = "3.6.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.5.0")>]
[<assembly: AssemblyFileVersionAttribute("3.5.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.5.0")>]
[<assembly: AssemblyVersionAttribute("3.6.0")>]
[<assembly: AssemblyFileVersionAttribute("3.6.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.6.0")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "3.5.0"
let [<Literal>] InformationalVersion = "3.5.0"
let [<Literal>] Version = "3.6.0"
let [<Literal>] InformationalVersion = "3.6.0"
6 changes: 6 additions & 0 deletions src/Paket.Core/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
match List.ofArray tokens with
| "nuget"::packageName::_ when packageNamePredicate packageName -> Some packageName
| _ -> None

let isPackageLine name line = tryMatchPackageLine ((=) name) line |> Option.isSome

let findGroupBorders groupName =
Expand Down Expand Up @@ -104,6 +105,11 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
|> Seq.map (fun p -> p.Name, p.VersionRequirement)
|> Map.ofSeq

member this.CheckIfPackageExistsInAnyGroup (packageName:PackageName) =
match groups |> Seq.tryFind (fun g -> g.Value.Packages |> List.exists (fun p -> p.Name = packageName)) with
| Some group -> sprintf "%sHowever, %O was found in group %O." Environment.NewLine PackageName group.Value.Name
| None -> ""

member __.Groups = groups

member this.SimplifyFrameworkRestrictions() =
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/InstallProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ let InstallIntoProjects(options : InstallerOptions, forceTouch, dependenciesFile
let package =
match model |> Map.tryFind (kv.Key, ps.Name) with
| Some (p,_) -> p
| None -> failwithf "%s uses NuGet package %O, but it was not found in the paket.lock file in group %O." referenceFile.FileName ps.Name kv.Key
| None -> failwithf "%s uses NuGet package %O, but it was not found in the paket.lock file in group %O.%s" referenceFile.FileName ps.Name kv.Key (lockFile.CheckIfPackageExistsInAnyGroup ps.Name)

let resolvedSettings =
[package.Settings; group.Options.Settings]
Expand Down
11 changes: 9 additions & 2 deletions src/Paket.Core/LockFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ type LockFile(fileName:string,groups: Map<GroupName,LockFileGroup>) =
| Some g -> g
| None -> failwithf "Group %O was not found in %s." groupName fileName

member this.CheckIfPackageExistsInAnyGroup (packageName:PackageName) =
match groups |> Seq.tryFind (fun g -> g.Value.Resolution.ContainsKey packageName) with
| Some group -> sprintf "%sHowever, %O was found in group %O." Environment.NewLine PackageName group.Value.Name
| None -> ""


/// Gets all dependencies of the given package
member this.GetAllNormalizedDependenciesOf(groupName,package:PackageName) =
let group = groups.[groupName]
Expand All @@ -514,7 +520,8 @@ type LockFile(fileName:string,groups: Map<GroupName,LockFileGroup>) =
if not group.Options.Strict then
for d,_,_ in package.Dependencies do
addPackage d
| None -> failwithf "Package %O was referenced, but it was not found in the paket.lock file in group %O." identity groupName
| None ->
failwithf "Package %O was referenced, but it was not found in the paket.lock file in group %O.%s" identity groupName (this.CheckIfPackageExistsInAnyGroup package)

addPackage package

Expand All @@ -525,7 +532,7 @@ type LockFile(fileName:string,groups: Map<GroupName,LockFileGroup>) =
match this.GetAllDependenciesOfSafe(groupName,package) with
| Some packages -> packages
| None ->
failwithf "Package %O was referenced, but it was not found in the paket.lock file in group %O." package groupName
failwithf "Package %O was referenced, but it was not found in the paket.lock file in group %O.%s" package groupName (this.CheckIfPackageExistsInAnyGroup package)

/// Gets all dependencies of the given package in the given group.
member this.GetAllDependenciesOfSafe(groupName:GroupName,package) =
Expand Down
10 changes: 4 additions & 6 deletions src/Paket.Core/ScriptGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ module ScriptGeneration =
seq {
for group, nuget, _ in deps.GetInstalledPackages() do
let model = deps.GetInstalledPackageModel(Some group, nuget)
let libs = model.GetLibReferences(framework) |> Seq.map FileInfo
let libs = model.GetLibReferences(framework) |> Seq.map (fun f -> FileInfo f)
let syslibs = model.GetFrameworkAssembliesLazy.Value
yield group, (libs, syslibs |> Set.toSeq)
}
Expand All @@ -242,7 +242,7 @@ module ScriptGeneration =
let assemblies =
let assemblyFilePerAssemblyDef =
assemblies
|> Seq.map (fun f -> f.FullName |> AssemblyDefinition.ReadAssembly, f)
|> Seq.map (fun (f:FileInfo) -> AssemblyDefinition.ReadAssembly(f.FullName:string), f)
|> dict

assemblyFilePerAssemblyDef.Keys
Expand Down Expand Up @@ -323,8 +323,7 @@ module ScriptGeneration =
let packagesFolder = DirectoryInfo(Path.Combine(rootFolder.FullName, Constants.PackagesFolderName))

let includeScriptsRootFolder =
Path.Combine((FileInfo dependenciesFile.DependenciesFile).Directory.FullName, Constants.PaketFilesFolderName, "include-scripts")
|> DirectoryInfo
DirectoryInfo(Path.Combine((FileInfo dependenciesFile.DependenciesFile).Directory.FullName, Constants.PaketFilesFolderName, "include-scripts"))

let getScriptFile groupName packageName =
getScriptFile includeScriptsRootFolder framework groupName packageName extension
Expand All @@ -343,8 +342,7 @@ module ScriptGeneration =

let getGroupFile group =
let folder = getScriptFolder includeScriptsRootFolder framework group
Path.Combine(folder.FullName, sprintf "include.%s.group.%s" (group.GetCompareString()) extension).ToLowerInvariant()
|> FileInfo
FileInfo(Path.Combine(folder.FullName, sprintf "include.%s.group.%s" (group.GetCompareString()) extension).ToLowerInvariant())

generateGroupScript dependenciesFile getGroupFile scriptWriter framework

Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/UpdateProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ let UpdatePackage(dependenciesFileName, groupName, packageName : PackageName, ne
let dependenciesFile = DependenciesFile.ReadFromFile(dependenciesFileName)

if not <| dependenciesFile.HasPackage(groupName, packageName) then
failwithf "Package %O was not found in paket.dependencies in group %O." packageName groupName
failwithf "Package %O was not found in paket.dependencies in group %O.%s" packageName groupName (dependenciesFile.CheckIfPackageExistsInAnyGroup packageName)

let dependenciesFile =
match newVersion with
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.5.0")>]
[<assembly: AssemblyFileVersionAttribute("3.5.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.5.0")>]
[<assembly: AssemblyVersionAttribute("3.6.0")>]
[<assembly: AssemblyFileVersionAttribute("3.6.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.6.0")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "3.5.0"
let [<Literal>] InformationalVersion = "3.5.0"
let [<Literal>] Version = "3.6.0"
let [<Literal>] InformationalVersion = "3.6.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.5.0")>]
[<assembly: AssemblyFileVersionAttribute("3.5.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.5.0")>]
[<assembly: AssemblyVersionAttribute("3.6.0")>]
[<assembly: AssemblyFileVersionAttribute("3.6.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.6.0")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "3.5.0"
let [<Literal>] InformationalVersion = "3.5.0"
let [<Literal>] Version = "3.6.0"
let [<Literal>] InformationalVersion = "3.6.0"
2 changes: 1 addition & 1 deletion src/Paket/PlatformTask.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type CopyRuntimeDependencies() =

for group,packageName in packagesToInstall do
match model |> Map.tryFind (group,packageName) with
| None -> failwithf "Package %O %O was not found in the install model" group packageName
| None -> failwithf "Package %O was not found in the install model in group %O.%s" group packageName (lockFile.CheckIfPackageExistsInAnyGroup packageName)
| Some (package,projectModel) ->

let files =
Expand Down

0 comments on commit 8e45f69

Please sign in to comment.