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

TargetFramework(s) confusion Check #11062

Merged
merged 2 commits into from
Dec 5, 2024
Merged

Conversation

JanKrivanek
Copy link
Member

Fixes #9880

Context

TargetFramework and TargetFrameworks properties should not be specified in the build script at the same time.

Testing

Tailored unit tests added

Notes

This calls to be unified with the #10635 Check. Let's do that in the separate PR, once this one is merged

@baronfel
Copy link
Member

baronfel commented Dec 2, 2024

Should this be in MSBuild or on the SDK? Meaning, are TFMs a general MSBuild concept or are they something that applies to managed languages/sdk-style projects only? My intuition was SDK-style projects only and so I would have expected to see this only on the SDK layer.

One thing I'd like to check is that it's very common to have a multi-TFM project, but then build or publish for a specific TFM at the command line using the '-f' parameter, which is passed to the build as a global property. Does this usage pattern trigger the check incorrectly?

@JanKrivanek
Copy link
Member Author

Should this be in MSBuild or on the SDK? Meaning, are TFMs a general MSBuild concept or are they something that applies to managed languages/sdk-style projects only? My intuition was SDK-style projects only and so I would have expected to see this only on the SDK layer.

I'd keep here now as we do not yet have a good concept of 'friend build-in checks'.
I'm open to complains and discussion though

One thing I'd like to check is that it's very common to have a multi-TFM project, but then build or publish for a specific TFM at the command line using the '-f' parameter, which is passed to the build as a global property. Does this usage pattern trigger the check incorrectly?

Global override is allowed. I put this to help link:
https://github.com/dotnet/msbuild/pull/11062/files#diff-e96bdd5e98d7e8729178bfbea183e2e16e385f10219a0d4121b2043a4883d5d9R92-R96

But it should be more specific and clear - I'll imporove.
Thanks for bringing this up!

@JanKrivanek JanKrivanek merged commit c2d92cb into main Dec 5, 2024
10 checks passed
@JanKrivanek JanKrivanek deleted the buildcheck/tfm-confusion branch December 5, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Built-in analyzer] TargetFramework and TargetFrameworks are both set
4 participants