[One .NET] ignore @(Content) from @(ProjectReference) #5308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #5299
When setting up
Mono.Android.NET-Tests, we had to workaround anerror with duplicate
@(Content)files:Android doesn't support the
@(Content)build action at all, and weemit a
XA0101warning if it is used. We even have a test for this.However, it appears that any
@(Content)from@(ProjectReference)items are currently brought over in .NET 6, as they get added to the
@(ResolvedFileToPublish)item group by the dotnet/sdk.Luckily there appears to be a
$(_GetChildProjectCopyToPublishDirectoryItems)MSBuild property we can set to skip this behavior:
https://github.com/dotnet/sdk/blob/955c0fc7b06e2fa34bacd076ed39f61e4fb61716/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L783-L794
We can set this by default, as we don't need to compute
@(Content)items in referenced projects. The library project will emit
XA0101and that is enough. I also updated a test that would have triggered
NETSDK1148which now works.I could also see a perf improvement in the
Mono.Android.NET-Testsproject on Windows: