Last active
October 8, 2018 10:58
-
-
Save nikolaia/9ea36a7fc70222d0eb6252881eaefc8a to your computer and use it in GitHub Desktop.
Ensure that NuGet Packages (packages.config) are consolidated
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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