Skip to content

Fix Windows test discovery in CI #4

Fix Windows test discovery in CI

Fix Windows test discovery in CI #4

Workflow file for this run

name: windows-ci
on:
push:
branches:
- main
- master
pull_request:
jobs:
build-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup NuGet
uses: NuGet/setup-nuget@v2
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Restore
run: nuget restore .\IOBusMonitor.sln
- name: Build Debug
run: msbuild .\IOBusMonitor.sln /p:Configuration=Debug /p:Platform="Any CPU"
- name: Run tests
shell: powershell
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vswhere) {
$vsRoot = & $vswhere -latest -products * -property installationPath
}
$searchRoots = @()
if ($vsRoot) { $searchRoots += (Join-Path $vsRoot "Common7\IDE") }
$searchRoots += @(
"${env:ProgramFiles}\Microsoft Visual Studio",
"${env:ProgramFiles(x86)}\Microsoft Visual Studio"
) | Where-Object { Test-Path $_ }
$vstest = $null
foreach ($root in $searchRoots) {
$candidate = Get-ChildItem $root -Recurse -Filter vstest.console.exe -ErrorAction SilentlyContinue |
Select-Object -First 1
if ($candidate) {
$vstest = $candidate.FullName
break
}
}
if (-not $vstest) { throw "vstest.console.exe not found" }
& $vstest .\IOBusMonitorLib.Tests\bin\Debug\net472\IOBusMonitorLib.Tests.dll