Skip to content

dotnet test does not isolate/consume cli parameters correctly #56338

Closed

Description

@LukasGelke

Describe the bug

We investigated building a somewhat dynamic pipeline for a mono-repo, to keep PR-pipeline times short.
Until the 'affected-test' solution is implemented though, we thought a combination of pre-generated yaml + pipeline self-checks would work.
however using the project name for --publish-azdo-run-name breaks the call.

Steps to reproduce

make a MsTest + MTP solution/project with global.json and all

{
  "test": {
    "runner": "Microsoft.Testing.Platform"
  }
}
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <LangVersion>latest</LangVersion>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <EnableMSTestRunner>true</EnableMSTestRunner>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MSTest" Version="4.4.0" />
    <PackageReference Include="Microsoft.Testing.Extensions.Retry" Version="2.4.0" />
    <PackageReference Include="Microsoft.Testing.Extensions.AzureDevOpsReport" Version="2.4.0" />
  </ItemGroup>

  <ItemGroup>
    <Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
  </ItemGroup>

</Project>
cd $dir/TestProject2
dotnet test --project TestProject2.csproj --no-build -- --report-azdo --publish-azdo-test-results --publish-azdo-run-name TestProject2.csproj --retry-failed-tests 3

Expected behavior

Tests run, and a TestRun named "TestProject2.csproj" gets created in the AZDO "Test" tab.

Actual behavior

fatal error and exit

Specifying a project for 'dotnet test' should be via '--project'.

Is this a regression?

i don't know. We've only been recently able to use Microsoft.Testing.Extensions.AzureDevOpsReport due to a bug, and our pipelines having been vstest based up until now

Are there any workarounds?

avoid ".sln" / ".csproj" in the --publish-azdo-run-name parameter

dotnet --info output

.NET SDK:
 Version:           10.0.401
 Commit:            e34a38d2ae
 Workload version:  10.0.400-manifests.a3b2712e
 MSBuild version:   18.9.11+e34a38d2a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26200
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\10.0.401\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
  Version:      10.0.12
  Architecture: x64
  Commit:       95017c711e

.NET SDKs installed:
  7.0.102 [C:\Program Files\dotnet\sdk]
  8.0.425 [C:\Program Files\dotnet\sdk]
  9.0.205 [C:\Program Files\dotnet\sdk]
  10.0.401 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 10.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 10.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.31 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 10.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  DOTNET_CLI_TELEMETRY_OPTOUT              [true]
  DOTNET_UPGRADEASSISTANT_TELEMETRY_OPTOUT [1]

global.json file:
  C:\Users\luge\source\repos\ClassLibrary1\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

IDE version

No response

Other details

Also, the documentation specifically states, that one should use a literal standalone -- to avoid ambiguity in parsing the command line. This seems contrary to what is happening:
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test-mtp#forward-arguments-to-the-test-application

Activity

  1. added
    untriaged
    on Sep 17, 2026
  2. locked and limited conversation to collaborators on Sep 17, 2026
  3. unlocked this conversation on Sep 17, 2026
  4. added
    needs team triage
    and removed
    untriaged
    on Sep 17, 2026
  5. github-actions commented on Sep 17, 2026

    @github-actions
    Contributor

    🎯 Agentic Issue Triage

    Thanks for the detailed repro! The dotnet test argument parser appears to treat any value containing .csproj/.sln passed to --publish-azdo-run-name (after --) as an implicit --project specifier, causing a false conflict error.

    Triage Assessment:

    • 🏷️ Labels: Area-dotnet test (MTP) Bug needs team triage Requires a full team discussion
    • 💻 Assignment: none | @dotnet/dotnet-testing
    • 🟨 Confidence: medium - Area is clearly dotnet test/MTP argument parsing, but the owning team could not be expanded from the snapshot.

    ➡️ Summary: dotnet test misparses forwarded MTP arguments like --publish-azdo-run-name when their value contains .csproj/.sln, triggering a false "specify project via --project" error. Please investigate the argument-forwarding/parsing logic for values resembling project file paths.

    Generated by 🏷️ Issue Triage for #56338 · copilot · auto · 65.4 AIC · ⌖ 7.98 AIC · ⊞ 14.6K · ◷

  6. Youssef1313 commented on Sep 21, 2026

    @Youssef1313
    Member

    @LukasGelke Does setting DOTNET_TEST_DISABLE_SWITCH_VALIDATION env variable to 1 fix that for you?

    We can potentially relax the error so that it's not produced when --project is already present. (there is also a similar path for sln I believe)

  7. added theissue type on Sep 21, 2026
  8. removed
    needs team triage
    on Sep 21, 2026
  9. Evangelink commented on Sep 21, 2026

    @Evangelink
    Member

    I confirm there is a bug for net10. It's fixed for net11 and main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions