Content Build Action for Resource Files in the Uno Platform

248 Views Asked by At

I have warnings building an Uno Platform app. Summarized, the warnings appear as below:

...\Source\Resources\Icon-256.svg : warning XA0101: @(Content) build action is not supported
...\Source\Properties\Default.rd.xml : warning XA0101: @(Content) build action is not supported

It seems the Uno Platform doesn't support the Content build action at all. However, there are two parts:

  1. What to do about the 'Default.rd.xml' file. This is automatically created by UWP projects and is required for the builds. In Uno/Xamarin this warning can safely be ignored. I'm sure there is a way to exclude it from the project file for Uno as well.
  2. The Icon-256.svg file is required and is referenced in XAML as below. I do need to find a way to include this file in the assembly.
    <Image Source="ms-appx:///Resources/LogoIconBlue-256.svg" />
    

The first idea for a solution would be to simply change the build action to Embedded Resource. This is what was even recommended here. However, I do not believe UWP supports using embedded resources in XAML like WPF did. In fact Martin already asked that and no solutions were found Referencing an Embedded Resource from UWP XAML.

So what is the 'official' recommendation for handling this situation? I would prefer not to fall back into loading the image using code-behind but I expect that might be the only way to do this.

1

There are 1 best solutions below

1
On

This warning is caused by Xamarin.Android itself as it does not know what to do with Content items.

This has been fixed in Uno 3.1 with the support of the StorageFile.GetFileFromApplicationUriAsync() method, which removes Content items to transform them into AndroidAsset items.