Skip to content

__SKIA__ constant is not defined in a library when targeting net9.0-desktop #18996

Open

Description

@MartinZikmund

Current behavior

In a Uno Platform library the __SKIA__ constant is not defined, even when compiling against net9.0-desktop. This is confusing as for net9.0-browserwasm the __WASM__ constant is defined correctly.

The reason seems to be that Uno.Skia.Runtime.XYZ packages are referenced only on executables:

<ItemGroup Condition="$(_IsExecutable) == 'true'">
	<_UnoProjectSystemPackageReference Include="Uno.WinUI.Runtime.Skia.Linux.FrameBuffer" ProjectSystem="true" />
	<_UnoProjectSystemPackageReference Include="Uno.WinUI.Runtime.Skia.MacOS" ProjectSystem="true" />
	<_UnoProjectSystemPackageReference Include="Uno.WinUI.Runtime.Skia.Wpf" ProjectSystem="true" />
	<_UnoProjectSystemPackageReference Include="Uno.WinUI.Runtime.Skia.X11" ProjectSystem="true" />

	<!-- Enable WPF Hardware acceleration over RDP, only if not specified by the project -->
	<RuntimeHostConfigurationOption 
			Include="Switch.System.Windows.Media.EnableHardwareAccelerationInRdp" 
			Value="true" 
			Exclude="@(RuntimeHostConfigurationOption)" />
</ItemGroup>

In case of WebAssembly the constant is defined in Uno.UI.Runtime.WebAssembly\buildTransitive\Uno.WinUI.Runtime.WebAssembly.targets, which is referenced as browserwasm references the runtime WebAssembly.

Expected behavior

Should be defined,

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

No response

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

Activity

  1. added
    kind/bug
    project/core-tools 🛠️
    difficulty/starter 🚀
    on Dec 4, 2024
  2. MartinZikmund commented on Dec 4, 2024

    @MartinZikmund
    MemberAuthor

    @jeromelaban is there a reason the Runtime.Skia packages cannot be referenced for non-executable -desktop projects? If yes, could we separate Uno.UI.Runtime.Skia itself as its own package and reference it similarly to how -browserwasm references Uno.UI.Runtime.WebAssembly?

  3. added
    kind/papercut
    on Dec 4, 2024
  4. jeromelaban commented on Dec 4, 2024

    @jeromelaban
    Member

    Why do you need to reference those packages? As for __SKIA__ , it's not an end-user define HAS_UNO_SKIA is.

  5. MartinZikmund commented on Dec 4, 2024

    @MartinZikmund
    MemberAuthor

    @jeromelaban neither is defined in a Uno library currently:

    image

    While they both are for wasm:

    image

    The problem is that for browserwasm the runtime package is referenced even in Uno Library project:

    image

    But it is not referenced for desktop:

    image

  6. Youssef1313 commented on Dec 4, 2024

    @Youssef1313
    Member

    IMO, DefineConstants should be provided by Uno.WinUI itself and not the runtime packages. Just a simple TargetFramework check there.

  7. Youssef1313 commented on Dec 4, 2024

    @Youssef1313
    Member

    For whatever reason, the runtime packages are only included when building an executable.

    <_UnoProjectSystemPackageReference Include="Uno.WinUI.Runtime.Skia.Linux.FrameBuffer" ProjectSystem="true" />
    <_UnoProjectSystemPackageReference Include="Uno.WinUI.Runtime.Skia.MacOS" ProjectSystem="true" />
    <_UnoProjectSystemPackageReference Include="Uno.WinUI.Runtime.Skia.Wpf" ProjectSystem="true" />
    <_UnoProjectSystemPackageReference Include="Uno.WinUI.Runtime.Skia.X11" ProjectSystem="true" />

  8. Youssef1313 commented on Dec 4, 2024

    @Youssef1313
    Member

    Also note the runtime packages will define HAS_UNO_SKIA_XYZ which is completely wrong. We can't determine the underlying platform in compile-time. So constants like HAS_UNO_SKIA_WPF does not make any sense. It used to make sense in past before single project.

    <DefineConstants>$(DefineConstants);UNO_REFERENCE_API;HAS_UNO_SKIA;HAS_UNO_SKIA_WPF</DefineConstants>

  9. added theissue type on Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

difficulty/starter 🚀kind/bugkind/papercutproject/core-tools 🛠️

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions