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

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

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

"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\1\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\1\s\pipeline.ps1:15 char:1
+ &$coverlet $unitTestFile.Name --target "dotnet" --targetargs "vstest  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At D:\a\1\s\pipeline.ps1:15 char:72
+ ... e --target "dotnet" --targetargs "vstest $($unitTestFile.Name) --logg ...
+                                                ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : NativeCommandFaile

d

powershell azure-devops azure-pipelines azure-pipelines-build-task
1个回答
0
投票

[我发现此参数$unitTestFile = gci -Recurse | ?{ $_.FullName -like "**\*Test*.dll" }占用了1个以上的dll文件,不得不将其减少为单个dll。那解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.