Add project name filter to solution (#4231)

This commit is contained in:
westey
2026-02-24 22:35:29 +00:00
committed by GitHub
Unverified
parent 9e3d6575ee
commit b8a59129de
2 changed files with 35 additions and 11 deletions
@@ -22,6 +22,10 @@
.PARAMETER Configuration
Optional MSBuild configuration used when querying TargetFrameworks. Defaults to Debug.
.PARAMETER ProjectNameFilter
Optional wildcard pattern to filter test project names (e.g., *UnitTests*, *IntegrationTests*).
When specified, only test projects whose filename matches this pattern are kept.
.PARAMETER OutputPath
Optional output path for the filtered .slnx file. If not specified, a temp file is created.
@@ -30,6 +34,10 @@
$filtered = ./eng/New-FilteredSolution.ps1 -Solution ./agent-framework-dotnet.slnx -TargetFramework net472
dotnet test --solution $filtered --no-build -f net472
.EXAMPLE
# Generate a solution with only unit test projects
./eng/New-FilteredSolution.ps1 -Solution ./agent-framework-dotnet.slnx -TargetFramework net10.0 -ProjectNameFilter "*UnitTests*" -OutputPath filtered-unit.slnx
.EXAMPLE
# Inline usage with dotnet test (PowerShell)
dotnet test --solution (./eng/New-FilteredSolution.ps1 -Solution ./agent-framework-dotnet.slnx -TargetFramework net472) --no-build -f net472
@@ -45,6 +53,8 @@ param(
[string]$Configuration = "Debug",
[string]$ProjectNameFilter,
[string]$OutputPath
)
@@ -70,6 +80,15 @@ $kept = @()
foreach ($proj in $testProjects) {
$projRelPath = $proj.GetAttribute("Path")
$projFullPath = Join-Path $solutionDir $projRelPath
$projFileName = Split-Path $projRelPath -Leaf
# Filter by project name pattern if specified
if ($ProjectNameFilter -and ($projFileName -notlike $ProjectNameFilter)) {
Write-Verbose "Removing (name filter): $projRelPath"
$removed += $projRelPath
$proj.ParentNode.RemoveChild($proj) | Out-Null
continue
}
if (-not (Test-Path $projFullPath)) {
Write-Verbose "Project not found, keeping in solution: $projRelPath"
+16 -11
View File
@@ -140,15 +140,21 @@ jobs:
popd
rm -rf "$TEMP_DIR"
- name: Generate filtered solution
- name: Generate filtered solutions
shell: pwsh
run: |
.github/workflows/New-FrameworkFilteredSolution.ps1 `
-Solution dotnet/agent-framework-dotnet.slnx `
-TargetFramework ${{ matrix.targetFramework }} `
-Configuration ${{ matrix.configuration }} `
-OutputPath dotnet/filtered.slnx `
-Verbose
$commonArgs = @{
Solution = "dotnet/agent-framework-dotnet.slnx"
TargetFramework = "${{ matrix.targetFramework }}"
Configuration = "${{ matrix.configuration }}"
Verbose = $true
}
.github/workflows/New-FrameworkFilteredSolution.ps1 @commonArgs `
-ProjectNameFilter "*UnitTests*" `
-OutputPath dotnet/filtered-unit.slnx
.github/workflows/New-FrameworkFilteredSolution.ps1 @commonArgs `
-ProjectNameFilter "*IntegrationTests*" `
-OutputPath dotnet/filtered-integration.slnx
- name: Run Unit Tests
shell: pwsh
@@ -165,13 +171,12 @@ jobs:
)
}
dotnet test --solution ./filtered.slnx `
dotnet test --solution ./filtered-unit.slnx `
-f ${{ matrix.targetFramework }} `
-c ${{ matrix.configuration }} `
--no-build -v Normal `
--report-xunit-trx `
--ignore-exit-code 8 `
--filter-query "/*UnitTests*/*/*/*" `
@coverageArgs
env:
# Cosmos DB Emulator connection settings
@@ -203,13 +208,13 @@ jobs:
working-directory: dotnet
if: github.event_name != 'pull_request' && matrix.integration-tests
run: |
dotnet test --solution ./filtered.slnx `
dotnet test --solution ./filtered-integration.slnx `
-f ${{ matrix.targetFramework }} `
-c ${{ matrix.configuration }} `
--no-build -v Normal `
--report-xunit-trx `
--ignore-exit-code 8 `
--filter-query "/*IntegrationTests*/*/*/*[Category!=IntegrationDisabled]"
--filter-not-trait "Category=IntegrationDisabled"
env:
# Cosmos DB Emulator connection settings
COSMOSDB_ENDPOINT: https://localhost:8081