Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powershell script for auto-generating Indice.Platform solution filter #412

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/publish_to_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,12 @@ jobs:
- name: Dotnet build SPAs
run: dotnet build Indice.Platform.Ecmascript.slnf --no-restore --configuration Release

# GENERATE SOLUTION FILTER
- name: Generate solution filter
run: ./generate-solution-filters.ps1 -solutionFile Indice.Platform.sln -ignoreFile solution-filters-ignore.yaml -outputFile Indice.Platform.slnf

- name: Dotnet build
run: dotnet build Indice.Platform.slnf --no-restore --configuration Release


# TEST
- name: Test with dotnet
Expand Down
49 changes: 0 additions & 49 deletions Indice.Platform.slnf

This file was deleted.

1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ before_build:
- ps: dotnet restore
build_script:
- ps: dotnet build Indice.Platform.Ecmascript.slnf --no-restore --configuration Release
- ps: ./generate-solution-filters.ps1 -solutionFile Indice.Platform.sln -ignoreFile solution-filters-ignore.yaml -outputFile Indice.Platform.slnf
- ps: dotnet build Indice.Platform.slnf --no-restore --configuration Release
test_script:
- ps: dotnet test --no-build --configuration Release
66 changes: 66 additions & 0 deletions generate-solution-filters.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
param (
[Parameter(Mandatory=$true)]
[string]$solutionFile,
[Parameter(Mandatory=$false)]
[string]$ignoreFile,
[Parameter(Mandatory=$true)]
[string]$outputFile
)

function Get-IgnoreList($ignoreFilePath) {
if (Test-Path $ignoreFilePath) {
return Get-Content -Path $ignoreFilePath
} else {
return @()
}
}

function Scan-Folder($solutionFile, $ignoreList) {
$solution = @{
path = $solutionFile
projects = @()
}

$directories = Get-ChildItem -Path "src" -Directory
foreach ($dir in $directories) {
if ($ignoreList -notcontains $dir.Name) {
$csprojFiles = Get-ChildItem -Path $dir.FullName -Filter *.csproj -File -ErrorAction SilentlyContinue
foreach ($csproj in $csprojFiles) {
$solution.projects += "src\$($dir.Name)\$($csproj.Name)"
}
}
}

$directories = Get-ChildItem -Path "test" -Directory
foreach ($dir in $directories) {
if ($ignoreList -notcontains $dir.Name) {
$csprojFiles = Get-ChildItem -Path $dir.FullName -Filter *.csproj -File -ErrorAction SilentlyContinue
foreach ($csproj in $csprojFiles) {
$solution.projects += "test\$($dir.Name)\$($csproj.Name)"
}
}
}

return $solution
}

function Generate-SolutionFilter {
param (
[Parameter(Mandatory=$true)]
[string]$solutionFile,
[Parameter(Mandatory=$false)]
[string]$ignoreFile,
[Parameter(Mandatory=$true)]
[string]$outputFile
)

$ignoreList = Get-IgnoreList -ignoreFilePath $ignoreFile
$solution = Scan-Folder -solutionFile $solutionFile -ignoreList $ignoreList

$solutionFilter = @{
solution = $solution
}
$solutionFilter | ConvertTo-Json -Depth 2 | Out-File -FilePath $outputFile
}

Generate-SolutionFilter -solutionFile $solutionFile -ignoreFile $ignoreFile -outputFile $outputFile
5 changes: 5 additions & 0 deletions solution-filters-ignore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Project folders to ignore from generated solution filter
Indice.Features.Cases.App
Indice.Features.Identity.AdminUI.App
Indice.Features.Messages.App
Indice.Features.Risk.App