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

Issue #123 fixing selection of xunit.exe based on installed framework… #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 21 additions & 1 deletion xUnit.net-dotCover/MRPP_xunit_dotcover.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,28 @@ try {
$xunit = Join-Path $workingDir "xunit.runner.console.*\tools\$xUnitExe" | Resolve-Path

if (-not $xunit) {
Write-Output "Xunit $xunit not found; searching for highest-compatible version..."

# Try finding xunit under framework specific folder
$xunit = Join-Path $workingDir "xunit.runner.console.*\tools\net4*\$xUnitExe" | Resolve-Path
$allXunitVersions = Join-Path $workingDir "xunit.runner.console.*\tools\net4*\$xUnitExe" | Resolve-Path

# Find which .Net Framework 4 is installed
$release = $(Get-ItemProperty -Path "HKLM:Software\Microsoft\NET Framework Setup\NDP\v4\Full" -Name Release -ErrorAction SilentlyContinue).Release

$frameworkVersion = switch($release) {
{ 378389, 378675, 378758, 379893 -contains $_ } { "net452" } # .NET Framework 4.5, 4.5.1 and 4.5.2
{ 393295, 393297 -contains $_ } { "net46" } # .NET Framework 4.6
{ 394254, 394271 -contains $_ } { "net461" } # .NET Framework 4.6.1
{ 394802, 394806 -contains $_ } { "net462" } # .NET Framework 4.6.2
{ 460798, 460805 -contains $_ } { "net47" } # .NET Framework 4.7
{ 461308, 461310 -contains $_ } { "net471" } # .NET Framework 4.7.1
{ 461808, 461814 -contains $_ } { "net472" } # .NET Framework 4.7.2
default { "net472" }
}

$xunit = $allXunitVersions | Where-Object { $_ -match $frameworkVersion } | Select-Object -First 1

Write-Output "Selected xunit.exe at $xunit based on installed .Net Framework $frameworkVersion ($release)"
}

if (-not $xunit) {
Expand Down