Skip to content

Commit

Permalink
Fix XML reporting on .NET Core
Browse files Browse the repository at this point in the history
Create and pass an `IO.FileStream` to `XmlWriter.Create()`, since on
.NET Core, it does not have an overload for a file path in a string.
  • Loading branch information
andyleejordan committed Oct 15, 2015
1 parent f2de259 commit f95c856
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Functions/TestResults.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,25 @@ function Export-NUnitReport {
NewLineOnAttributes = $false
}

$xmlFile = $null
$xmlWriter = $null
try {
$xmlWriter = [Xml.XmlWriter]::Create($Path,$settings)
$xmlFile = [IO.File]::Create($Path)
$xmlWriter = [Xml.XmlWriter]::Create($xmlFile, $settings)

Write-NUnitReport -XmlWriter $xmlWriter -PesterState $PesterState -LegacyFormat:$LegacyFormat

$xmlWriter.Flush()
$xmlFile.Flush()
}
finally
{
if ($null -ne $xmlWriter) {
try { $xmlWriter.Close() } catch {}
}
if ($null -ne $xmlFile) {
try { $xmlFile.Close() } catch {}
}
}
}

Expand Down

0 comments on commit f95c856

Please sign in to comment.