dotnet / arcade

Tools that provide common build infrastructure for multiple .NET Foundation projects.
MIT License
657 stars 331 forks source link

Building a custom test project in-tree in dotnet/runtime triggers a MSB4120 warning. #14018

Open lateralusX opened 10 months ago

lateralusX commented 10 months ago

Looks like msbuild enabled additional warning in 17.7.2 that shows up when building an in-tree project in dotnet/runtime:

...\.nuget\packages\microsoft.dotnet.build.tasks.targetframework\8.0.0-beta.23422.1\buildMultiTargeting\Microsoft.DotNet.Build.Tasks.TargetFramework.targets(54,49): message : MSB4120: Item 'InnerBuildProjectsWithBestTargetFramework' definition within target references itself via (qualified or unqualified) metadatum 'Identity'. This can lead to unintended expansion and cross-applying of pre-existing items. More info: https://aka.ms/msbuild/metadata-self-ref ...

More info here, https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-batching?view=vs-2022#item-self-referencing-metadata-inside-of-a-target

Issue is located here, https://github.com/dotnet/arcade/blob/main/src/Microsoft.DotNet.Build.Tasks.TargetFramework/src/buildMultiTargeting/Microsoft.DotNet.Build.Tasks.TargetFramework.targets#L53

changing %(Identify) -> %(_BestTargetFramework.Identity) resolves the warning.

dotnet/runtime:

.net8 RC1

msbuild:

MSBuild version 17.7.2+d6990bcfa for .NET Framework 17.7.2.37605

missymessa commented 9 months ago

Thanks @lateralusX, would you mind opening a PR into Arcade to fix this? Thanks!

ViktorHofer commented 9 months ago

Note that this isn't a warning or error, it's just an informational message. Still, it would be good to do something to avoid the message.