Skip to content

dotnet CLI should return a list of target frameworks of the project or use target framework as a filter. #47093

@voroninp

Description

@voroninp

Is your feature request related to a problem? Please describe.

When my solution contains a mix of projects which target different framework versions (or multitargeted projects)
I have no standard way to select projects by target framework version. I need this for CI/CD pipeline.
For example, to run tests for .NET 9 I need to select only the projects which target it.
If I specify the target framework, I get an error:

dotnet test -f net9.0
Common.Infrastructure.Persistence.Tests net9.0 failed with 1 error(s) (0.3s)
C:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1005: Assets file 'tests\Common.Infrastructure.Persistence.Tests\obj\project.assets.json' doesn't have a target for 'net9.0'. Ensure that restore has run and that you have included 'net9.0' in the TargetFrameworks for your project.
  Common.Domain.Tests net9.0 failed with 1 error(s) (0.3s)

Sure it does not, because this project does not target .NET 9.

In other words, now I cannot say: "Run all tests in solution targeting .NET 9 for projects which support .NET 9"

Describe the solution you'd like

Provide either a standard way to list the target frameworks of a project or an option to use the framework version as a filter in commands that accept template paths, solutions, or lists of projects.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions