Created
September 30, 2015 08:13
-
-
Save cwe1ss/c1d623a24a8b7841b785 to your computer and use it in GitHub Desktop.
ProjectsMissingInSolution.ps1
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
$ErrorActionPreference = "Stop" | |
# Parameters | |
$baseFolder = (Get-Item (Get-Location)).Parent.FullName + "\" | |
$slnName = "All.sln" | |
$excludePatterns = @("Some\Exclusion") | |
# ################################################################ | |
$slnFile = Join-Path $baseFolder $slnName | |
$slnContent = [System.IO.File]::ReadAllText($slnFile) | |
$projectFiles = [System.IO.Directory]::GetFiles($baseFolder, "*.csproj", [System.IO.SearchOption]::AllDirectories) | |
$projectFiles += [System.IO.Directory]::GetFiles($baseFolder, "*.xproj", [System.IO.SearchOption]::AllDirectories) | |
# Exclude projects from configured patterns | |
[regex] $excludeMatchRegEx = ‘(?i)‘ + (($excludePatterns | foreach {[regex]::escape($_)}) –join “|”) + ‘’ | |
$projectFiles = $projectFiles | | |
where { $excludePatterns -eq $null -or $_.Replace($baseFolder, "") -notmatch $excludeMatchRegEx} | |
# Find missing projects | |
$missingProjects = $projectFiles | | |
Where { $slnContent.IndexOf($_.Replace($baseFolder, ""), [System.StringComparison]::OrdinalIgnoreCase) -lt 0; } | |
# Output results | |
$missingProjects | |
"" | |
"Projects missing in solution: " + $missingProjects.Count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment