microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.47k stars 2.6k forks source link

Allow dotnet test with publish --results-directory to be customized #17255

Open woeterman94 opened 1 year ago

woeterman94 commented 1 year ago

Type: Feature

Enter Task Name: .NET Core - test

Environment

Server - Azure Pipelines

Issue Description

Issue Description Checking the Publish test results and code coverage option sets --results-directory to the agent's temporary directory, making it difficult to isolate a single build's test output when publishing the results of multiple data collectors.

Recommendation: Allow --results-directory to be overridden (via textbox) when Publish test results and code coverage is checked.

This would allow users to harvest the output for publishing to additional code coverage tools or overcome shortcomings in the existing tooling (such as the code coverage tab only providing a link instead of an html report).

woeterman94 commented 1 year ago

Passing in --results-directory actually sets the parameter twice because it is already set by default and causes an error: image

##[debug]   h:\_work_agent_2\4\TestResults
"C:\Program Files\dotnet\dotnet.exe" test h:\_work_agent_2\4\s\App\myproject.Common.Tests\myproject.Common.Tests.csproj --logger trx --results-directory h:\_work_agent_2\_temp --configuration release --no-restore --collect "Code coverage" --logger trx --results-directory h:\_work_agent_2\4\TestResults
Option '--results-directory' only accepts a single argument but 2 were provided.
Hefaistos68 commented 1 year ago

Yep, am stuck now with the same issue. Didnt find a way to avoid that the --results-directory parameter is automatically passed instead of using my parameter provided in the arguments. Kind of annoying.

Hefaistos68 commented 1 year ago

documentation says: publishTestResults automatically adds "--logger trx --results-directory $(Agent.TempDirectory)" but even without this option those parameters are always added it seems. Currently I have only command, projects and arguments specified and still see those parameters appended to the test commandline.

woeterman94 commented 1 year ago

Did you try with publishTestResults set to false? That worked for me.

Hefaistos68 commented 1 year ago

Didn't try false, but removed the argument completely (which I suppose should be equal to false) PS: Note to self: read the WHOLE documentation, it states "default: true" or as such, if not provided then the --result-directory will be set by the CLI anyway.

github-actions[bot] commented 11 months ago

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

MisinformedDNA commented 11 months ago

Still wanted.

EshitaD commented 8 months ago

Hi @woeterman94, may i know what agent you are using? self hosted or Microsoft hosted ?

woeterman94 commented 8 months ago

I was using Microsoft hosted agents back then.Op 26 dec. 2023 06:54 schreef EshitaD @.***>: Hi @woeterman94, may i know what agent you are using? self hosted or Microsoft hosted ?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

mscholze commented 6 months ago

Didn't try false, but removed the argument completely (which I suppose should be equal to false) PS: Note to self: read the WHOLE documentation, it states "default: true" or as such, if not provided then the --result-directory will be set by the CLI anyway.

Thats correct. Documentation says: publishTestResults Default value: true

https://learn.microsoft.com/de-de/azure/devops/pipelines/tasks/reference/dotnet-core-cli-v2?view=azure-pipelines

Setting this to false worked for me too. I use a different task to publish the test results.