Skip to content

[BuildCheck Suggestion]: Handle empty value of TargetFramework #11630

Description

@stan-sz

Summary

For

<TargetFramework />
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>

or

<TargetFramework></TargetFramework>
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>

We get

error BC0107: Project foo.csproj specifies 'TargetFrameworks' property 'net472;netstandard2.0' and 'TargetFramework' property '' at the same time. This will lead to 'TargetFrameworks' being ignored and build will behave as single-targeted.

Consider handling the case of $(TargetFramework) having empty value to be valid in this case.

Background and Motivation

A repo can have a default TF with several projects multi-targeting.

Sample issue or antipattern that the check should be flagging

<TargetFramework />
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>

or

<TargetFramework></TargetFramework>
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>

Should be valid usages

Sample output

No response

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: BuildCheckBuildCheck SuggestionSuggestion for a built in MSBuild analyzer. Label should be applied together with 'Area: BuildCheck'help wantedIssues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions