Created
September 14, 2015 22:08
-
-
Save trayburn/df980482a5a86a7f5499 to your computer and use it in GitHub Desktop.
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
$excludes = @("node_modules", "packages", ".git", ".vs") | |
function Get-SolutionFiles() { | |
( | |
@(Get-ChildItem *.sln) + | |
@(Get-ChildItem -Directory | ? { $excludes -notcontains $_.Name } | % { Get-ChildItem $_ -Recurse -Filter *.sln }) | |
) | |
} | |
function Analyze-Solutions() { | |
Get-SolutionFiles | % { | |
$retVal = New-Object -TypeName PSObject | | |
Add-Member Path $_.FullName -PassThru | | |
Add-Member Name $_.Name -PassThru | | |
Add-Member Projects @() -PassThru | |
$sln = Get-Content $_.FullName | |
$slnDir = $_.Directory | |
$sln | | |
? { $_ -match "^Project\(.*\) = \`".*\`", \`"(.*)\`", \`".*\`"" } | | |
% { "$slnDir\$($matches[1])" } | | |
% { | |
$info = Get-Item $_ | |
$prj = [xml](Get-Content $info.FullName) | |
$prjObj = New-Object -TypeName PSObject | | |
Add-Member Path $info.FullName -PassThru | | |
Add-Member Name $info.Name -PassThru | |
$refs = $prj.Project.ItemGroup.Reference.Include | % { | |
New-Object -TypeName PSObject | | |
Add-Member Name $_ -PassThru | | |
Add-Member Project $prjObj -PassThru | |
} | |
$prjObj | Add-Member References $refs | |
$retVal.Projects += $prjObj | |
} | |
$retVal | |
} | |
} | |
$analysis = Analyze-Solutions | |
$foo.Projects.References | Group-Object Name | Sort-Object Count | ? { $_.Count -gt 1 } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment