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

AvaloniaResource inclusion results in erroneous embedding when resources are outside of project folder #16056

Open
fitdev opened this issue Jun 18, 2024 · 2 comments · May be fixed by #16118
Open

Comments

@fitdev
Copy link
Contributor

fitdev commented Jun 18, 2024

Describe the bug

Given referenced Avalonia resources:

<ItemGroup>
<AvaloniaResource Include="..\avaresdir\**">
    <!-- LinkBase does not seem to matter - whether it is present or not -->
    <LinkBase>avaresdir</LinkBase>
   </AvaloniaResource>
</ItemGroup>

and the dir structure:

src\app.csproj
avaresdir\*.png

The resources get resolved as avares://AppProjectName/../avaresdir/resourcefile.png instead of avares://AppProjectName/avaresdir/resourcefile.png. The generated -AvaloniaResources resource stores resource paths as /../avaresdir/resourcefile.png.

This would all be ok, but it fails at runtime, because regardless how the resource is referenced in xaml (whether as avares://avaresdir/resourcefile.png or avares://AppProjectName/avaresdir/resourcefile.png or averes://AppProjectName/../avaresdir/resourcefile.png or avaresdir/resourcefile.png or /../avaresdir/resourcefile.png), it complains that file is not found, presumably because the asset loader loads resources as /avaresdir/resourcefile.png.

To Reproduce

Include resources from outside project folder:

<ItemGroup>
<AvaloniaResource Include="..\avaresdir\**">
    <!-- LinkBase does not seem to matter - whether it is present or not -->
    <LinkBase>avaresdir</LinkBase>
   </AvaloniaResource>
</ItemGroup>

Expected behavior

Regardless of whether the files are physically coming from, they should be properly included/embedded. LinkBase should be taken into account when including such resources from external directories.

Avalonia version

11.1

OS

Windows

Additional context

Furthermore there are related issues:

  • File Symlinks are not supported - fails at compile time with totally unrelated error message. In other words if the included files, are not real files, but symlinks, it fails entirely, which is pretty disappointing since symlink support is important.
  • <AvaloniaResource> does not support Visible element is when included from external dir will not be shown in Solution Explorer in any case, again just because it is not coming from within the project dir should not make it not appear in solution explorer when LinkBase is specified.
@fitdev fitdev added the bug label Jun 18, 2024
@maxkatz6
Copy link
Member

LinkBase is not handled at all indeed. But Link is.

@maxkatz6
Copy link
Member

If anybody want to take a look at this issue, LinkBase support can be added in this part of the code:
https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Build.Tasks/GenerateAvaloniaResourcesTask.cs#L40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants