Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BuildCheck Suggestion]: Non-SDK project defines TargetFramework #10635

Open
rainersigwald opened this issue Sep 9, 2024 · 0 comments
Open
Labels
Area: BuildCheck BuildCheck Suggestion Suggestion for a built in MSBuild analyzer. Label should be applied together with 'Area: BuildCheck' triaged

Comments

@rainersigwald
Copy link
Member

Summary

A buildcheck to catch errors like the one that is the root cause of #10629.

Background and Motivation

In the modern .NET SDK, you define <TargetFramework> or <TargetFrameworks> to control what the project output targets. Older non-SDK projects have other properties for this (like TargetFrameworkVersion). Currently it is allowed and ignored to specify TargetFramework . . . but that can lead to a lot of confusion if someone does it, thinks they have retargeted the project, and then moves on.

Sample issue or antipattern that the check should be flagging

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>22dfcebd-2972-484f-9b0c-d1c6f28626eb</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>ClassLibrary2</RootNamespace>
    <AssemblyName>ClassLibrary2</AssemblyName>
    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <Deterministic>true</Deterministic>
	  <TargetFrameworks>net46;net8.0</TargetFrameworks> <!-- THIS IS BOGUS -->
  </PropertyGroup>

Sample output

No response

@rainersigwald rainersigwald added BuildCheck Suggestion Suggestion for a built in MSBuild analyzer. Label should be applied together with 'Area: BuildCheck' Area: BuildCheck labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BuildCheck BuildCheck Suggestion Suggestion for a built in MSBuild analyzer. Label should be applied together with 'Area: BuildCheck' triaged
Projects
None yet
Development

No branches or pull requests

2 participants