Skip to content

Dotnet test doesn't run separate TargetFrameworks in parallel #19147

@ghost

Description

Issue Description

Attempting to run multiple unit tests in parallel for a test project with multiple target frameworks. However, there is no way to do this out of the box. The DispatchToInnerBuildsWithVSTestTarget target in Microsoft.Common.CrossTargeting.targets\ImportAfter\Microsoft.TestPlatform.CrossTargeting.targets that recursively calls VSTest does not set the BuildInParallel option on the MSBuild task. Exerpt from version 5.0.302 of the sdk:

  <Target Name="DispatchToInnerBuildsWithVSTestTarget" Returns="@(InnerOutput)">
    <ItemGroup>
      <_TargetFramework Include="$(TargetFrameworks)" />
    </ItemGroup>
    <MSBuild Projects="$(MSBuildProjectFile)"
             Condition="'$(TargetFrameworks)' != '' "
             Targets="$(InnerVSTestTargets)"
             Properties="TargetFramework=%(_TargetFramework.Identity);VSTestNoBuild=true"
             ContinueOnError="ErrorAndContinue">
      <Output ItemName="InnerOutput" TaskParameter="TargetOutputs" />
    </MSBuild>
  </Target>

Steps to Reproduce

  1. Create a new mstest project, e.g. dotnet new mstest
  2. enable multiple target frameworks for the test, with <TargetFrameworks>net462;netcoreapp2.1;net5.0</TargetFrameworks>
  3. run dotnet test or dotnet msbuild /restore /t:VSTest /p:TestInParallel=true

Expected

Tests for each targetframework run in parallel, as long as the user selects the appropriate command line option or configuration.

Actual

Tests never run in parallel.

Data

Analysis

Versions & Configurations

aaronla@aaronla-rabbit:PowerPlatform$ dotnet --version
5.0.302

aaronla@aaronla-rabbit:PowerPlatform$ dotnet msbuild --nologo --version
16.10.2.30804

Regression?

Attach a binlog

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions