Created
August 26, 2017 03:21
-
-
Save Kevin-Bronsdijk/13c34b913f5045e4000d39ae17a3974c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Package | |
{ | |
[String]$id | |
[String]$version | |
[String]$targetFramework | |
[String]$path | |
} | |
function GatherPackageInfo([string]$path) { | |
$packages = @() | |
[xml]$XmlDocument = Get-Content -Path $path | |
Foreach($p in $XmlDocument.Packages.package) { | |
$pak = New-Object Package | |
$pak.id = $p.id | |
$pak.version = $p.version | |
$pak.targetFramework = $p.targetFramework | |
$pak.path = $path | |
$packages += $pak | |
} | |
return $packages | |
} | |
function FindAllProjectFiles ([string]$sourceFolder) | |
{ | |
$allPackages = @() | |
$filesToWorkWith = gci $sourceFolder -recurse -filter "packages.config" -file -ErrorAction SilentlyContinue | |
ForEach ($file in $filesToWorkWith) | |
{ | |
$allPackages += $packages = GatherPackageInfo($file.FullName); | |
} | |
return $allPackages | |
} | |
function ListPackagesWithMultipleVersions ([string]$sourceFolder) | |
{ | |
$allresults = FindAllProjectFiles($sourceFolder) | |
return $allresults | group -p id | | |
where { $_.count -ge 2 } | % { $_.Group } | | |
sort -u id, version | | |
group -p id | | |
where { $_.count -ge 2 } | % { $_.Group } | | |
sort -u id, version | |
} | |
function CheckIfPackageExits ([string]$sourceFolder, [string]$filter) | |
{ | |
$allresults = FindAllProjectFiles($sourceFolder) | |
return $allresults | where {$_.id -Like $filter} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment