Skip to content

Uno Class Library with non-Windows TFM can't use <Content Include="..."/> #8266

@Arlodotexe

Description

@Arlodotexe

Current behavior

If you create an Uno Class Library with some code and a small addition to the .csproj:

image

<ItemGroup>
	<Content Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
	<Content Include="**\*.cs" Exclude="bin\**\*.cs;obj\**\*.cs" />
</ItemGroup>

This content is included in the build output and can be accessed via StorageFile.GetFileFromApplicationUriAsync() under UWP and WinAppSDK (uap10.0.18362;net6.0-windows10.0.19041.0):

image
image

However, under any other TFMs where Uno.UI is used, including netstandard2.0, net6.0-ios, net6.0-macos ,net6.0-maccatalyst, net6.0-android, and older TFMs that don't use NET6, the content is neither included in the final build nor accessible with StorageFile.GetFileFromApplicationUriAsync():

image

Skia.WPF:
image

Skia.GTK: (WSL)
image

Droid:
image

WebAssembly:
image

Expected behavior

Behavior should be consistent between all platforms.

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

Attached is a project with a complete, minimal repro of the issue, and should be ready-to-run assuming you've got the proper dependencies and tooling (.NET 6 / MAUI / VS 2022).

This is the same project used to create the screenshots above.
ConsistentContentIncludeBehavior.zip

Workaround

The only potential workaround is to create a custom MSBuild Target that

  1. Checks the head for all referenced projects
  2. Checks each referenced project for any usages of <Content Include="..."/>
  3. Manually copy the files to the project head's "Assets" folder

Then, modify all of your code to only use the Assets folder.

Works on UWP/WinUI

Yes

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia, Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

4.0.11

Affected platforms

iOS, Android, WebAssembly, WebAssembly renderers for Xamarin.Forms, macOS, Skia (WPF), Skia (GTK on Linux/macOS/Windows), Skia (Tizen)

IDE

Visual Studio 2022

IDE version

17.0.5

Relevant plugins

No response

Anything else we need to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty/tbdCategorizes an issue for which the difficulty level needs to be defined.kind/bugSomething isn't workingtriage/untriagedIndicates an issue requires triaging or verification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions