Closed fabianoriccardi closed 3 weeks ago
You will need to reference it via
ms-appx:///ClassLibrary/Assets/square.png
I will try it as soon as possible! May you link where this is explained on Microsoft docs?
I can't find any documentation about it either... 😅I agree this should be mentioned somewhere.
I found out by trial and error (if you check the build output directory you can see a ClassLibrary\Assets
folder, which exactly matches the URI path.
I confirm it works, thanks!
I hope the maintainers will add a mention about it in the official docs.
Hi @fabianoriccardi and @whiskhub. Thanks for raising the concern about this not being mentioned in the docs anywhere. I'll be adding a section to this page on the Windows dev docs on Microsoft Learn this week. Look for a new section about resources in libraries on this page soon: https://learn.microsoft.com/windows/apps/windows-app-sdk/mrtcore/images-tailored-for-scale-theme-contrast
If you ever see anything missing or incorrect in the docs, we love feedback. There's a Feedback button (thumbs up/down) on each page that opens a popup where you can describe the issue. Many pages also have a link at the bottom of the page to submit GitHub Issues against the docs. PRs are always welcome too (click the pencil icon to begin an edit on a page)! :)
Describe the bug
I would embed few files as
Content
in a Class Library project. Theese files such be used only by the Library. However, they seem to be ignored, because they are missing when I try to load them. If I move these files in the main project (a regular Blank App, Packaged (WinUI 3 in Desktop)) they can be loaded using the usualms-appx:///Assets/....
path.For now, I solved including these file as Embedded Resource, but I still wonder if this is an intended behavior or a bug.
Steps to reproduce the bug
Create an empty Class Library and a Blank App. Reference the ClassLibrary (Class1) into the BlackApp (App1). Insert a content file (e.g. Class1/Assets/square.png).
try to load the file from the Class1:
It will throw a not found exception. But, if I move the
square.png
toApp1/Assets/square.png
, the image is properly loaded.Expected behavior
I would be able to load Content files located in a ClassLibrary.
Screenshots
No response
NuGet package version
Windows App SDK 1.5.5: 1.5.240627000
Packaging type
Packaged (MSIX)
Windows version
Windows 10 version 22H2 (19045, 2022 Update)
IDE
Visual Studio 2022
Additional context
No response