程序 'coverlet.exe' 未能 运行: 文件名或扩展名太长位于 D:\a\s\pipeline.ps1:15 char:1

Program 'coverlet.exe' failed to run: The filename or extension is too longAt D:\a\1\s\pipeline.ps1:15 char:1

我正在尝试 运行 azure devOps 构建管道中的 shell 脚本以将测试结果代码覆盖率发布到 azure 管道中的覆盖率选项卡中,但我收到此错误。这是我的脚本

"install tools:"
&dotnet tool install dotnet-reportgenerator-globaltool --tool-path . --version 4.0.12
&dotnet tool install coverlet.console --tool-path . --version 1.4.1

"`nmake reports dir:"
mkdir .\reports

"`nrun tests:"
$unitTestFile = gci -Recurse | ?{ $_.FullName -like "**\*Test*.dll" }
Write-Host "`$unitTestFile value: $unitTestFile"

$coverlet = "$pwd\coverlet.exe"

"calling $coverlet for $($unitTestFile.FullName)"
&$coverlet $unitTestFile.FullName --target "dotnet" --targetargs "vstest $($unitTestFile.FullName) --logger:trx" --format "cobertura"

"`ngenerate report(s)"
gci -Recurse | 
    ?{ $_.Name -eq "coverage.cobertura.xml" } | 
    %{ &"$pwd\reportgenerator.exe" "-reports:$($_.FullName)" "-targetdir:reports" "-reporttypes:HTMLInline;HTMLChart" }

更新 - 错误日志

D:\a\s\packages\NUnit3TestAdapter.3.15.1\build\netcoreapp2.0\NUnit3.TestAdapter.dll
Program 'coverlet.exe' failed to run: The filename or extension is too longAt D:\a\s\pipeline.ps1:15 char:1
+ &$coverlet $unitTestFile.Name --target "dotnet" --targetargs "vstest  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At D:\a\s\pipeline.ps1:15 char:72
+ ... e --target "dotnet" --targetargs "vstest $($unitTestFile.Name) --logg ...
+                                                ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : NativeCommandFaile

d

我发现这个参数 $unitTestFile = gci -Recurse | ?{ $_.FullName -like "**\*Test*.dll" } 需要超过 1 个 dll 文件,并且必须将其减少为单个 dll。这解决了问题。