@@ -6,13 +6,19 @@ Set-StrictMode -Version Latest
66$ErrorActionPreference = " Stop"
77
88$yamlModule = " powershell-yaml"
9- $moduleInstalled = Get-Module - ListAvailable - Name $yamlModule
10- if (-not $moduleInstalled ) {
9+ $retries = 5
10+ while (-not (Get-Module - ListAvailable - Name $yamlModule ) -and $retries -gt 0 )
11+ {
12+ if ($retries -lt 5 )
13+ {
14+ Start-Sleep - Seconds 10
15+ }
1116 Write-Debug " The module '$yamlModule ' is not installed. Installing..."
1217 Install-Module - Name $yamlModule - Scope CurrentUser - Force
18+ $retries --
1319}
1420
15- import-module $yamlModule
21+ Import-Module $yamlModule
1622
1723$separator = [IO.Path ]::DirectorySeparatorChar.ToString()
1824$lf = if ([Environment ]::OSVersion.Platform -eq [PlatformID ]::Win32NT) { " `r`n " } else { " `n " }
@@ -23,88 +29,102 @@ $repoRoot = Join-Path $scriptDir ('..' + $separator) -Resolve
2329# Load configuration
2430$configPath = Join-Path $scriptDir $ConfigFile
2531Write-Debug " Loading configuration file $configPath "
26- if (-not (Test-Path $configPath )) {
32+ if (-not (Test-Path $configPath ))
33+ {
2734 Write-Error " Config file '$configPath ' does not exist."
2835 exit 1
2936}
30- try {
37+
38+ try
39+ {
3140 $config = Get-Content $configPath | ConvertFrom-Yaml
3241}
33- catch {
42+ catch
43+ {
3444 Write-Error " Error parsing config file '$configPath ': $_ "
3545 exit 1
3646}
3747
3848# Get list of all projects in solution
3949Write-Debug " Searching the repository for projects..."
40- $projectPaths = Get-ChildItem - Path $repoRoot - Recurse - Filter * .csproj |
41- Select-Object - ExpandProperty FullName |
42- ForEach-Object { $_.Replace ($repoRoot , ' ' ).Replace(' \' , ' /' ) } # Force linux style separators for glob matching
50+ $projectPaths = Get-ChildItem - Path $repoRoot - Recurse - Filter * .csproj | `
51+ Select-Object - ExpandProperty FullName | `
52+ ForEach-Object { $_.Replace ($repoRoot , ' ' ).Replace(' \' , ' /' ) } # Force linux style separators for glob matching
4353Write-Debug " Found $ ( $projectPaths.Count ) projects"
4454
4555# Generate a solution filter for each filter config
46- foreach ($filter in $config.filterConfigs ){
56+ foreach ($filter in $config.filterConfigs )
57+ {
4758 Write-Debug " Processing filter $ ( $filter.outputPath ) "
4859
4960 $includedProjects = @ ()
5061
5162 # Process includes, if present
5263 if ($filter.ContainsKey (" include" ))
5364 {
54- # Add include groups
55- if ($filter.include.ContainsKey (" groups" ))
56- {
57- foreach ($group in $filter.include.groups ){
58- Write-Debug " Include $group "
59- foreach ($include in $config.groupConfigs .$group ){
60- $includedProjects += ($projectPaths | Where-Object { $_ -like $include })
65+ # Add include groups
66+ if ($filter.include.ContainsKey (" groups" ))
67+ {
68+ foreach ($group in $filter.include.groups )
69+ {
70+ Write-Debug " Include $group "
71+ foreach ($include in $config.groupConfigs .$group )
72+ {
73+ $includedProjects += ($projectPaths | Where-Object { $_ -like $include })
74+ }
6175 }
6276 }
63- }
64-
65- # Add ad-hoc includes
66- if ($filter.include.ContainsKey (" patterns" ))
67- {
68- foreach ($include in $filter.include.patterns ){
69- Write-Debug " Include $include "
70- $includedProjects += ($projectPaths | Where-Object { $_ -like $include })
77+
78+ # Add ad-hoc includes
79+ if ($filter.include.ContainsKey (" patterns" ))
80+ {
81+ foreach ($include in $filter.include.patterns )
82+ {
83+ Write-Debug " Include $include "
84+ $includedProjects += ($projectPaths | Where-Object { $_ -like $include })
85+ }
7186 }
72- }
7387 }
7488
7589 # Process excludes, if present
7690 if ($filter.ContainsKey (" exclude" ))
7791 {
78- # Remove exclude groups
79- if ($filter.exclude.ContainsKey (" groups" ))
80- {
81- foreach ($group in $filter.exclude.groups ){
82- Write-Debug " Exclude $group "
83- foreach ($exclude in $config.groupConfigs .$group ){
84- $includedProjects = ($includedProjects | Where-Object { $_ -notlike $exclude })
85- }
92+ # Remove exclude groups
93+ if ($filter.exclude.ContainsKey (" groups" ))
94+ {
95+ foreach ($group in $filter.exclude.groups )
96+ {
97+ Write-Debug " Exclude $group "
98+ foreach ($exclude in $config.groupConfigs .$group )
99+ {
100+ $includedProjects = ($includedProjects | Where-Object { $_ -notlike $exclude })
101+ }
102+ }
86103 }
87- }
88-
89- # Remove ad-hoc excludes
90- if ($filter.exclude.ContainsKey (" patterns" ))
91- {
92- foreach ($exclude in $filter.exclude.patterns ){
93- Write-Debug " Exclude $exclude "
94- $includedProjects = ($includedProjects | Where-Object { $_ -notlike $exclude })
104+
105+ # Remove ad-hoc excludes
106+ if ($filter.exclude.ContainsKey (" patterns" ))
107+ {
108+ foreach ($exclude in $filter.exclude.patterns )
109+ {
110+ Write-Debug " Exclude $exclude "
111+ $includedProjects = ($includedProjects | Where-Object { $_ -notlike $exclude })
112+ }
95113 }
96- }
97114 }
98115
99116 # Remove duplicates and sort
100117 $includedProjects = $includedProjects | Select-Object - Unique | Sort-Object
101118 Write-Debug " Writing filter matching $ ( $includedProjects.Count ) projects"
102119
103120 # Start filter file
104- $solution = if ($filter.ContainsKey (' solution' )) {
105- $filter.solution
106- } else {
107- $config.defaultSolution
121+ $solution = if ($filter.ContainsKey (' solution' ))
122+ {
123+ $filter.solution
124+ }
125+ else
126+ {
127+ $config.defaultSolution
108128 }
109129 $content = " {
110130 `" solution`" : {
@@ -113,11 +133,13 @@ foreach($filter in $config.filterConfigs){
113133
114134 # Add all the projects we want to include
115135 $firstProject = $true ;
116- foreach ($project in $includedProjects ) {
136+ foreach ($project in $includedProjects )
137+ {
117138 # Solution Filter files use escaped Windows style path separators
118- $escapedProject = $project.Replace (' /' , ' \\' )
139+ $escapedProject = $project.Replace (' /' , ' \\' )
119140 $line = " $lf "" $escapedProject "" "
120- if (! $firstProject ) {
141+ if (! $firstProject )
142+ {
121143 $line = " ," + $line
122144 }
123145 $firstProject = $false ;
@@ -132,10 +154,10 @@ foreach($filter in $config.filterConfigs){
132154}
133155'@
134156
135- # Output filter file
136- $outputPath = Join-Path $repoRoot $filter.outputPath
137- $content | Set-Content $outputPath
138- Write-Debug " Created $outputPath "
157+ # Output filter file
158+ $outputPath = Join-Path $repoRoot $filter.outputPath
159+ $content | Set-Content $outputPath
160+ Write-Debug " Created $outputPath "
139161}
140162
141163# Update solution files from Sentry.sln
0 commit comments