You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Set the Link metadata if it's not already set, if the item wasn't defined in a shared project, and the item is outside of the project directory.
Check whether the item was defined in a shared project by checking whether the extension of the defining project was .projitems.
Check whether an item is inside the project directory by seeing if the FullPath starts with EnsureTrailingSlash(MSBuildProjectDirectory)
The FullPath and the MSBuildProjectDirectory will both already be normalized full paths.
The call to [MSBuild]::ValueOrDefault() is there in order to allow calling StartsWith on the FullPath value, since it's
not possible to call a string method on a metadata item directly. The intrinsic ValueOrDefault() will be more
performant than calling String.Copy(), which has been used for this in other contexts, but actually makes a copy
of the string data.
-->
<LinkCondition="'%(Link)' == '' And '%(DefiningProjectExtension)' != '.projitems' And !$([MSBuild]::ValueOrDefault('%(FullPath)', '').StartsWith($([MSBuild]::EnsureTrailingSlash($(MSBuildProjectDirectory)))))">%(LinkBase)%(RecursiveDir)%(Filename)%(Extension)</Link>
<LinkCondition="'%(Link)' == '' And '%(DefiningProjectExtension)' != '.projitems' And !$([MSBuild]::ValueOrDefault('%(FullPath)', '').StartsWith($([MSBuild]::EnsureTrailingSlash($(MSBuildProjectDirectory)))))">%(LinkBase)%(RecursiveDir)%(Filename)%(Extension)</Link>
<LinkCondition="'%(Link)' == '' And '%(DefiningProjectExtension)' != '.projitems' And !$([MSBuild]::ValueOrDefault('%(FullPath)', '').StartsWith($([MSBuild]::EnsureTrailingSlash($(MSBuildProjectDirectory)))))">%(LinkBase)%(RecursiveDir)%(Filename)%(Extension)</Link>
<LinkCondition="'%(Link)' == '' And '%(DefiningProjectExtension)' != '.projitems' And !$([MSBuild]::ValueOrDefault('%(FullPath)', '').StartsWith($([MSBuild]::EnsureTrailingSlash($(MSBuildProjectDirectory)))))">%(LinkBase)%(RecursiveDir)%(Filename)%(Extension)</Link>
<LinkCondition="'%(Link)' == '' And '%(DefiningProjectExtension)' != '.projitems' And !$([MSBuild]::ValueOrDefault('%(FullPath)', '').StartsWith($([MSBuild]::EnsureTrailingSlash($(MSBuildProjectDirectory)))))">%(LinkBase)%(RecursiveDir)%(Filename)%(Extension)</Link>
</EmbeddedResource>
</ItemGroup>
This has two consequences:
It prevents the easy way of getting these files outside project cone to show in sln explorer
Xaml interpretation can actually change based on the Link so the impact of not generating a Link as expected can change the application behavior. I forget the details here, but I observed this in customer app.
I'm unsure if the WindowsDesktop SDK should be handling it or if we should add to above. We probably need to do this for Resource items as well.
Regarding consequence number 2 above, I've seen this cause functional differences when trying to load XAML as a resource. The resource path changes based on the link path of the XAML so previously working code can break without <Link>.
Is there documentation for LinkBase besides #1246?
When EnableDefaultItems=false, does it imply SetLinkMetadataAutomatically==false ?
What about when EnableDefaultCompileItems=false, EnableDefaultPageItems=false etc. hold - do they imply that SetLinkMetadataAutomatically==false for the corresponding ItemGroup elements?
(Filing bugs from my notes after customer visit exploring porting large WPF app to .NET core 3)
This:
Does not work as it does for Compile, EmbeddedResource, AdditionalFiles, EmbeddedResource:
sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.DefaultItems.targets
Lines 201 to 246 in 9543229
This has two consequences:
I'm unsure if the WindowsDesktop SDK should be handling it or if we should add to above. We probably need to do this for Resource items as well.
cc @dsplaisted @vatsan-madhavan
The text was updated successfully, but these errors were encountered: