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

ms-appx:// references in XAML are not redirected when PublishSingleFile is enabed #9468

Closed
lhak opened this issue Mar 20, 2024 · 3 comments
Closed
Labels
bug Something isn't working closed-Fixed Described behavior has been fixed. fix-released The fix has been in a release (experimental, preview, stable, or servicing). team-Markup Issue for the Markup team
Milestone

Comments

@lhak
Copy link

lhak commented Mar 20, 2024

Describe the bug

When PublishSingleFile is enabled, all assets are extracted to a temporary folder. However, all references in XAML to files (e.g. images) using ms-appx:// still point to the application folder and thus do not work.

Steps to reproduce the bug

  1. Create an application with single file deployment
  2. Add an image file to the application and reference it with ms-appx://
  3. Observe that the file will be used correctly when the app is started from visual studio but not when it is published as a single file

Expected behavior

All ms-appx:// references should be redirected

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.5.1: 1.5.240311000

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

@lhak lhak added the bug Something isn't working label Mar 20, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Mar 20, 2024
@ghost1372
Copy link
Contributor

ghost1372 commented Mar 20, 2024

You can exclude your assets from publish single file so this can be fixed.

<ItemGroup> 
   <Content Update="Plugin.dll">
     <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
   </Content> 
</ItemGroup>

https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli

But in general, this bug must be fixed

@Scottj1s
Copy link
Member

@lhak Thanks for reporting this.

The issue is that the files under your Assets folder are not being copied to the publish output. This is due to a difference in behavior between copying package output and copying publish output. For package output, all Assets are copied regardless of each Content element's CopyToOutputDirectory metadata. However, for publish output, unless CopyToOutputDirectory is specified, the item is not copied.

There are two ways to resolve this:

  1. Ensure your assets all have CopyToOutputDirectory set correctly (e.g., to PreserveNewest)
  2. Add a target that automatically applies this setting, as the WinUI Gallery solution has done.

@Scottj1s
Copy link
Member

The target mentioned above (solution #2) is now included in Windows App SDK 1.6. Closing as resolved.

@codendone codendone added the closed-Fixed Described behavior has been fixed. label Aug 22, 2024
@codendone codendone added this to the WinAppSDK 1.6 milestone Aug 22, 2024
@codendone codendone added the fix-released The fix has been in a release (experimental, preview, stable, or servicing). label Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working closed-Fixed Described behavior has been fixed. fix-released The fix has been in a release (experimental, preview, stable, or servicing). team-Markup Issue for the Markup team
Projects
None yet
Development

No branches or pull requests

5 participants