Skip to content

UseMSBuildTestInfrastructure doesn't work for multi-tfm #37712

@MarcoRossignoli

Description

@MarcoRossignoli

This PR added the support for the /t:Test target to msbuild dotnet/msbuild#9193 and the target it's imported using the prop UseMSBuildTestInfrastructure

Now that's landed inside the .NET SDK I'm trying to use it and it's working as expected for single tfm.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
</Project>
dotnet msbuild /t:Test -p:UseMSBuildTestInfrastructure=true
MSBuild version 17.10.0-preview-23615-03+abc2f4620 for .NET

But it's failing for multi-tm

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net9.0;net8.0</TargetFrameworks>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
</Project>
 dotnet msbuild /t:Test -p:UseMSBuildTestInfrastructure=true /bl
...\msbuildtest.csproj : error MSB4057: The target "Test" does not exist in the project.

Digging deeper into it I've noticed that the Microsoft.Common.Test.targets is imported only in case of single tfm
Imported
NotImported

cc: @Forgind @rainersigwald @novacole @Evangelink @nohwnd

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