Added project name to test run title for DotNetCoreCli@2 - #22509
Open
Jeremy Morren (jeremy-morren) wants to merge 1 commit into
Open
Jeremy Morren (jeremy-morren) wants to merge 1 commit into
Jeremy Morren (jeremy-morren) wants to merge 1 commit into
Conversation
Jeremy Morren (jeremy-morren)
requested review from
a team and
Tarun Ramsinghani (tarunramsinghani)
as code owners
September 14, 2026 14:09
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Jeremy Morren (jeremy-morren)
force-pushed
the
dotNetCli2
branch
from
September 14, 2026 14:10
56afebb to
ebee40b
Compare
Added a parameter to DotNetCoreCli@2 to allow including the project name in the test run title
Jeremy Morren (jeremy-morren)
force-pushed
the
dotNetCli2
branch
from
September 17, 2026 01:27
ebee40b to
b484e6a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
When
DotNetCoreCLI@2runsdotnet testagainst several projects withpublishTestResults: true, all results are published under the singletestRunTitle(or the default title). In the Tests tab this shows up asMyTitle_1,MyTitle_2, ..., so you have to open each run to find out which project it belongs to. The usual workaround is one task per test project, with each title hardcoded in the pipeline.Issues requesting this feature:
$(TestProjectName)-style option)Task Name
DotNetCoreCLIV2 (
DotNetCoreCLI@2)Description
Adds an optional
appendToTestRunTitlepick list input to thetestcommand:testRunTitleprojectName<testRunTitle> <project file name without extension>, e.g.{testRunTitle} Alpha.TestsprojectPath<testRunTitle> <project path relative to Build.SourcesDirectory>, e.g.{testRunTitle} src/Alpha.Tests/Alpha.Tests.csprojIf
testRunTitleis empty, the suffix alone becomes the title.When the input is set:
$(Agent.TempDirectory)/TestResults_<index>), so results from different projects are never mixed.projectPath, the path is relative toBuild.SourcesDirectory, falling back toSystem.DefaultWorkingDirectory. Separators are normalised to/. A project outside the repository root keeps its path as given.UnknownAppendToTestRunTitle) and nothing is appended.--logger trx) and Microsoft.Testing.Platform (--report-trx) are supported. The results directory arguments are now built by one shared helper instead of inline in two places.Example:
Risk Assessment (Low / Medium / High)
Low. The feature is opt-in and the new input defaults to empty, which keeps the existing code path: the same arguments, a single publish of
Agent.TempDirectoryand the same title. The only change on that path is moving the--logger trx/--report-trxargument strings into a helper; the strings themselves are unchanged.Change Behind Feature Flag (Yes / No)
No. The change is opt-in through a new input that is off by default, so it doesn't need a feature flag.
Tech Design / Approach
PublishTestResultstakes one title for every file it is given. A single shared results directory would mix trx files across projects.$(TestProjectName)-style placeholder insidetestRunTitle(as suggested in Cannot set unique testRunTitle when using dotnet test for multiple projects #19795). I chose a separate input because that placeholder uses the same$(...)syntax as pipeline variable macros. If a pipeline variable with that name exists, the agent replaces the placeholder with its value before the task runs. A pick list has no such collision and can be validated.Documentation Changes Required (Yes/No)
Yes. The
DotNetCoreCLI@2task reference needs the newappendToTestRunTitleinput. The help text intask.jsondescribes it.Unit Tests Added or Updated (Yes / No)
Yes. Two new L0 tests in
Tests/L0.ts:publishtestsAppendProjectName: two projects produce two dotnet invocations and two publishes, titledMy Tests Alpha.TestsandMy Tests Beta.Tests.publishtestsAppendProjectPath: the same, titled with the repository-relative pathsAlpha.Tests/Alpha.Tests.csprojandBeta.Tests/Beta.Tests.csproj.The existing test command L0 tests cover the default path, where the input is not set.
Additional Testing Performed
TODO: pipeline run(s) with the privately uploaded task (VSTest and MTP, Windows and Linux).
Logging Added/Updated (Yes/No)
Yes. One warning is added for an unrecognised
appendToTestRunTitlevalue. It logs only the input value.Telemetry Added/Updated (Yes/No)
No.
Rollback Scenario and Process (Yes/No)
Yes. Removing
appendToTestRunTitlefrom a pipeline restores the previous behaviour. Reverting this PR only removes the input.Dependency Impact Assessed and Regression Tested (Yes/No)
No dependency changes. Only
DotNetCoreCLIV2is touched. TODO: regression run.Checklist