Skip to content

# dotnet test --max-parallel-test-assemblies forwarded to MSBuild as unknown switch when mixing /p: properties (regression in SDK 10.0.103) #53201

@TRB7

Description

@TRB7

Summary

When running dotnet test against a solution file (.sln) with both --max-parallel-test-assemblies and /p: MSBuild properties in the same command, SDK 10.0.103 forwards --max-parallel-test-assemblies verbatim to the underlying MSBuild invocation as a raw command-line switch. MSBuild does not recognize it, causing a hard MSB1001 failure.

This was working correctly in prior SDK versions (confirmed working in .NET 8/9).


Environment

SDK version 10.0.103 (/usr/share/dotnet/sdk/10.0.103)
OS Ubuntu (GitHub Actions ubuntu-latest)
Invocation target Solution file (.sln)

Steps to reproduce

dotnet test MyApp.sln \
  --configuration Release \
  --no-build \
  --verbosity normal \
  --max-parallel-test-assemblies 1 \
  /p:CollectCoverage=true \
  /p:CoverletOutputFormat=opencover

The presence of at least one /p: property alongside --max-parallel-test-assemblies appears to be required to trigger the issue (the /p: properties cause dotnet test to route through the MSBuild VSTest target).


Expected behavior

--max-parallel-test-assemblies 1 is consumed by the dotnet test CLI host (as it was in .NET 8/9) and is not forwarded to MSBuild. Tests run with a maximum of 1 parallel assembly.


Actual behavior

dotnet test forwards --max-parallel-test-assemblies 1 as a raw argument appended to the MSBuild invocation after the solution file path:

MSBUILD : error MSB1001: Unknown switch.
  Full command line: '/usr/share/dotnet/sdk/10.0.103/MSBuild.dll
    -maxcpucount
    --verbosity:m
    -tlp:default=auto
    --property:VSTestLogger="trx%3bLogFilePrefix=test-results"
    --property:VSTestNoBuild=true
    --property:VSTestResultsDirectory="..."
    --property:Configuration=Release
    --property:CollectCoverage=true
    --property:CoverletOutputFormat=opencover
    --property:VSTestVerbosity=normal
    --property:VSTestArtifactsProcessingMode=collect
    --property:VSTestSessionCorrelationId=...
    --target:VSTest
    --verbosity:normal
    -nodereuse:false
    -nologo
    MyApp.sln
    --max-parallel-test-assemblies 1'   ← should never reach MSBuild

Switches appended by response files:
Switch: --max-parallel-test-assemblies

Regression

This worked correctly in .NET SDK 8.x and 9.x. The --max-parallel-test-assemblies flag was introduced specifically for dotnet test and should be fully consumed before any MSBuild delegation occurs.


Workaround

Replace the CLI flag with the equivalent MSBuild property that the VSTest target natively understands:

# Remove:  --max-parallel-test-assemblies 1
# Add:     /p:VSTestMaxCpuCount=1

dotnet test MyApp.sln \
  --configuration Release \
  --no-build \
  --verbosity normal \
  /p:VSTestMaxCpuCount=1 \
  /p:CollectCoverage=true \
  /p:CoverletOutputFormat=opencover

Additional context

The issue appears to be in the argument parsing/forwarding layer of dotnet test when the command is delegated to MSBuild's VSTest target via a solution file. The flag is not being stripped from the argument list before the MSBuild invocation is constructed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions