将最后生成的.Coverage转换为TFS 2017中SonarQubee的coveragexml

问题描述 投票:0回答:1

我正在使用.Net Core Test --collect "Code coverage"生成覆盖率文件,我需要将其转换为声纳,问题是我不知道生成的文件的名称,该文件放置在具有GUID名称的文件夹中TestResults文件夹下的文件名本身就是一个GUID

以下脚本可以将.coverage文件转换为coveragexml,但对于整个工作目录都是这样

Get-ChildItem -Recurse -Filter "*.coverage" | % {
$outfile = "$([System.IO.Path]::GetFileNameWithoutExtension($_.FullName)).coveragexml"
$output = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($_.FullName), $outfile)
"Analyse '$($_.Name)' with output '$outfile'..."
. "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Dynamic Code Coverage Tools\codecoverage.exe" analyze /output:$output $_.FullName
}

但是这会转换整个目录,几天后会有很多构建,我要做的就是转换当前构建生成的.coverage文件,因此我需要能够隔离由以下生成的.coverage文件当前版本。

powershell tfs azure-devops sonarqube tfsbuild
1个回答
0
投票

因此,您只想获取最后创建的代码覆盖率文件,可以过滤Get-ChiledItem结果以获取最后一个:

Get-ChildItem -Recurse -Filter "*.coverage" | sort LastWriteTime | select -last 1
© www.soinside.com 2019 - 2024. All rights reserved.