Skip to content

Instantly share code, notes, and snippets.

@nikolaia
Last active October 8, 2018 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikolaia/9ea36a7fc70222d0eb6252881eaefc8a to your computer and use it in GitHub Desktop.
Save nikolaia/9ea36a7fc70222d0eb6252881eaefc8a to your computer and use it in GitHub Desktop.
Ensure that NuGet Packages (packages.config) are consolidated
type PackageReferenceFile = NuGet.PackageReferenceFile
Target "NuGetPackagesConsolidated" <| fun _ ->
!! (sprintf "./src/%s*/packages.config" appName)
-- "**/obj/**/packages.config"
|> Seq.map PackageReferenceFile
|> Seq.collect (fun prf -> prf.GetPackageReferences())
|> Seq.groupBy (fun pr -> pr.Id)
|> Seq.filter (fun p -> (snd p |> Seq.distinct |> Seq.length) > 1 )
|> Seq.map (fun p -> fst p , snd p |> Seq.distinct)
|> function
| packages when packages |> Seq.isEmpty -> ()
| packages ->
seq {
yield "The following packages are not consolidated:"
for (k,v) in packages do
yield (sprintf " Package: %s Versions: %A" k v)
yield "You need to consolidate packages across the solution:"
yield " * Right click on the solution inside VS"
yield " * Choose Manage NuGet Packages for Solution"
yield " * Choose the Consolidate tab"
yield " * Make sure you sync the package versions" }
|> Seq.iter (printfn "%s")
failwith "Packages not consolidated"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment