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

Support for assets provided by library #2502

Closed
1 of 12 tasks
Daoting opened this issue Jan 20, 2020 · 4 comments · Fixed by #10134
Closed
1 of 12 tasks

Support for assets provided by library #2502

Daoting opened this issue Jan 20, 2020 · 4 comments · Fixed by #10134
Assignees
Labels
difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/enhancement New feature or request project/resources 🈷️ Categorizes an issue or PR as relevant to resources and localization (Resources, Assets,...)

Comments

@Daoting
Copy link
Contributor

Daoting commented Jan 20, 2020

Current behavior

  1. I create project with template "Cross-Platform Library".
  2. Add the image file to the Assets directory of this project.
  3. Set the build action to Content.
  4. xaml
    <Image Source="ms-appx:///Bs.Kehu/Assets/header.png" />

The image is displayed in uwp and android. But in iOS:

2020-01-20 11:05:49.261049+0800 UnoApp[12385:168687] \^[[41m\^[[30mfail\^[[39m\^[[22m\^[[49m: Windows.UI.Xaml.Media.ImageSource[0]
      Unable to locate bundle resource [ms-appx:///Bs.Kehu/Assets/header.png]

Maybe it's not a bug. But I failed to get any help about this. I propose to add some help about this.
Thanks!

Expected behavior

How to reproduce it (as minimally and precisely as possible)

Environment

Nuget Package:

Package Version(s):

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Windows
  • Build tasks
  • Solution Templates

Visual Studio:

  • 2017 (version: )
  • 2019 (version: )
  • for Mac (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

@Daoting Daoting added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jan 20, 2020
@jeromelaban jeromelaban changed the title [iOS] The Assets image is not displayed in uno library (not shared library) Support for assets provided by library Jan 20, 2020
@jeromelaban jeromelaban added kind/enhancement New feature or request and removed kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jan 20, 2020
@jeromelaban
Copy link
Member

Thanks for the report! Indeed, this scenario is not yet supported.

@francoistanguay francoistanguay modified the milestone: 3.1 Aug 29, 2020
@agneszitte agneszitte added the project/resources 🈷️ Categorizes an issue or PR as relevant to resources and localization (Resources, Assets,...) label Sep 21, 2020
@ajpinedam ajpinedam added this to the 3.4 milestone Nov 23, 2020
@ajpinedam ajpinedam self-assigned this Nov 24, 2020
@ajpinedam ajpinedam removed this from the 3.4 milestone Dec 15, 2020
@jeromelaban jeromelaban added the difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. label Feb 15, 2021
@MartinZikmund MartinZikmund added difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Jun 1, 2021
@MartinZikmund
Copy link
Member

@ajpinedam Are you planning to look into this?

@Juansero29
Copy link

This could be very useful for our use case, specially for fonts assets

@jeromelaban
Copy link
Member

Until this issue is fixed, when working with a solution which contains a project with custom assets (assuming it is in a project named MyLibrary and the assets are located in a folder named Assets), a workaround can be to include the files as content from the consuming project (a project head, for instance), as such:

<ItemGroup>
    <Content Include="..\MyLibrary\Assets\**" Link="Assets\%(RecursiveDir)\%(FileName)%(Extension)" />
</ItemGroup>

This content could be located in a separate msbuild file (e.g. ProjectAssets.props), such as this one:

<Project>
   <ItemGroup>
      <Content Include="$(MSBuildThisFileDirectory)Assets\**" 
               Link="Assets\%(RecursiveDir)\%(FileName)%(Extension)" />
   </ItemGroup>
</Project>

And include it in the projects heads as follows:

<Import Project="..\MyLibrary\ProjectAssets.props" />

The path of the assets will local to the project head, though, with this workaround. WinUI prefixes assets with the library containing the assets (e.g. ms-apps://MyLibrary/Assets/MyAsset.txt), and this workaround will not include the library name.

The same workaround can be applied to nuget packages, and the contentfile convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/medium 🤔 Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUI kind/enhancement New feature or request project/resources 🈷️ Categorizes an issue or PR as relevant to resources and localization (Resources, Assets,...)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants