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

Duplicate assets when referencing a chain of nuget packages #8857

Closed
jeromelaban opened this issue Sep 11, 2023 · 2 comments · Fixed by microsoft/WindowsAppSDK#4124
Closed
Labels
area-Resources bug Something isn't working needs-triage Issue needs to be triaged by the area owners team-Markup Issue for the Markup team
Milestone

Comments

@jeromelaban
Copy link

jeromelaban commented Sep 11, 2023

Describe the bug

Given an app that references a nuget package called PackageA, which itself references a nuget package called PackageB.

If PackageB contains an asset called File01.txt, the creation of the PackageA package will also include a reference to File01.txt in its own pri file.

When the app references PackageA, assets from PackageA and PackageB are elected to be placed in the app layout, causing the file name File01.txt to be present twice, and will cause the build to fail.

Steps to reproduce the bug

  • Create a nuget package MyPackage01 which references Uno.Material.WinUI
  • Take the nuget package and place it in a local folder source for nuget
  • In a separate solution, create an app that references the MyPackage01 nuget package (not a direct project reference)
  • Build the app and you'll notice that there duplicate layout files.

Expected behavior

App build works properly when using these packages.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.4.0: 1.4.230822000

Windows version

No response

Additional context

In most of Uno Platform packages, we're now including this workaround (works with both UWP and WinUI) :

<!-- Workaround to avoid duplicate assets https://github.com/microsoft/microsoft-ui-xaml/issues/8857 -->
<Target Name="AdjustGetPackagingOutput1" AfterTargets="GetMrtPackagingOutputs">
	<Message Importance="high" Text="Applying NuGet packaging workaround for dependent PRI files exclusion" />
	<ItemGroup>
		<_OtherPriFiles Include="@(PackagingOutputs)" Condition="'%(Extension)' == '.pri' and ('%(PackagingOutputs.ReferenceSourceTarget)' == 'ProjectReference' or '%(PackagingOutputs.NugetSourceType)'=='Package')" />
		<PackagingOutputs Remove="@(_OtherPriFiles)" />
	</ItemGroup>
</Target>
<Target Name="AdjustGetPackagingOutput2" BeforeTargets="AddPriPayloadFilesToCopyToOutputDirectoryItems">
	<Message Importance="high" Text="Applying NuGet packaging workaround for dependent PRI files exclusion" />
	<ItemGroup>
		<_OtherPriFiles1 Include="@(_ReferenceRelatedPaths)" Condition="'%(Extension)' == '.pri' and ('%(_ReferenceRelatedPaths.ReferenceSourceTarget)' == 'ProjectReference' or '%(_ReferenceRelatedPaths.NugetSourceType)'=='Package')" />
		<_ReferenceRelatedPaths Remove="@(_OtherPriFiles1)" />
		<_OtherPriFiles2 Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' == '.pri' and ('%(ReferenceCopyLocalPaths.ReferenceSourceTarget)' == 'ProjectReference' or '%(ReferenceCopyLocalPaths.NugetSourceType)'=='Package')" />
		<ReferenceCopyLocalPaths Remove="@(_OtherPriFiles2)" />
	</ItemGroup>
</Target>

which prevents files from direct nuget package references to be incorrectly included in a package being built.

@duncanmacmichael
Copy link
Member

Fixed in the 1.4.5 release; marking as completed.

@bpulliam bpulliam added this to the WinAppSDK 1.5 milestone Feb 29, 2024
@SongOfYouth
Copy link

Fixed in the 1.4.5 release; marking as completed.

The xbf file of nuget package lost when i build the exe project which referenced the package, then raise 'xaml parse error' after run it.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Resources bug Something isn't working needs-triage Issue needs to be triaged by the area owners team-Markup Issue for the Markup team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants