Skip to content

Commit 2798d8e

Browse files
CopilotT-Gro
andauthored
Support built-in dotnet commands in regression test template (#19171)
* Initial plan * Support built-in dotnet commands in regression test template Modified regression-test-jobs.yml to: - Skip file validation for commands starting with "dotnet" - Execute dotnet commands directly using Invoke-Expression - Maintain existing file-based script support - Handle both Windows and Linux scenarios appropriately This allows tests like UMX_Slow_Repro to use "dotnet build" directly without requiring a build script file. Co-authored-by: T-Gro <[email protected]> * Add security clarification comments for buildScript usage Added comments to clarify that buildScript comes from pipeline YAML configuration, not external user input, making Invoke-Expression safe in this context. Co-authored-by: T-Gro <[email protected]> * Execute provided buildScript on Windows instead of hardcoded build.proj Changed Windows file-based script execution to use the provided buildScript parameter instead of assuming build.proj exists. Now Windows behavior matches Linux - it executes the actual script specified in the configuration. Co-authored-by: T-Gro <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: T-Gro <[email protected]>
1 parent 7720c6b commit 2798d8e

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

eng/templates/regression-test-jobs.yml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,23 @@ jobs:
6060
Write-Host "Repository structure:"
6161
Get-ChildItem -Name
6262
63-
Write-Host "Verifying build script exists: ${{ item.buildScript }}"
64-
if (Test-Path "${{ item.buildScript }}") {
65-
Write-Host "Build script found: ${{ item.buildScript }}"
63+
# Check if buildScript is a built-in dotnet command or a file-based script
64+
# Note: buildScript comes from the pipeline YAML configuration (testMatrix parameter),
65+
# not from external user input, so it's safe to use
66+
$buildScript = "${{ item.buildScript }}"
67+
if ($buildScript -like "dotnet*") {
68+
Write-Host "Build command is a built-in dotnet command: $buildScript"
69+
Write-Host "Skipping file existence check for built-in command"
6670
} else {
67-
Write-Host "Build script not found: ${{ item.buildScript }}"
68-
Write-Host "Available files in root:"
69-
Get-ChildItem
70-
exit 1
71+
Write-Host "Verifying build script exists: $buildScript"
72+
if (Test-Path $buildScript) {
73+
Write-Host "Build script found: $buildScript"
74+
} else {
75+
Write-Host "Build script not found: $buildScript"
76+
Write-Host "Available files in root:"
77+
Get-ChildItem
78+
exit 1
79+
}
7180
}
7281
displayName: Checkout ${{ item.displayName }} at specific commit
7382
@@ -144,15 +153,23 @@ jobs:
144153
Write-Host "============================================"
145154
Write-Host ""
146155
147-
# Use dotnet pack with binary logging on Windows to generate binlog files
148-
# On Linux, execute the build script directly
149-
if ($IsWindows) {
150-
Write-Host "Running: dotnet pack build.proj -bl:build.binlog"
151-
dotnet pack build.proj -bl:build.binlog
156+
$buildScript = "${{ item.buildScript }}"
157+
158+
# Check if it's a built-in dotnet command or a file-based script
159+
# Note: buildScript comes from the pipeline YAML configuration (testMatrix parameter),
160+
# not from external user input, so using Invoke-Expression is safe here
161+
if ($buildScript -like "dotnet*") {
162+
Write-Host "Executing built-in command: $buildScript"
163+
Invoke-Expression $buildScript
164+
} elseif ($IsWindows) {
165+
# Execute the provided script on Windows
166+
Write-Host "Executing file-based script: $buildScript"
167+
& ".\$buildScript"
152168
} else {
153-
Write-Host "Executing: ${{ item.buildScript }}"
154-
chmod +x "${{ item.buildScript }}"
155-
bash -c "./${{ item.buildScript }}"
169+
# Execute the provided script on Linux
170+
Write-Host "Executing file-based script: $buildScript"
171+
chmod +x "$buildScript"
172+
bash -c "./$buildScript"
156173
}
157174
$exitCode = $LASTEXITCODE
158175

0 commit comments

Comments
 (0)