diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs index f6e718155eb4..8c5cfcff7cce 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.cs @@ -495,6 +495,13 @@ private string GenerateGlobalResources(IEnumerable files, Xa writer.AppendLineInvariant("using {0};", _defaultNamespace); writer.AppendLineInvariant(""); + // If a failure happens here, this means that the _isWasm was not properly set as the DefineConstants msbuild property + // was not populated. This can happen when the property is set through a target with the "CreateProperty" task, and the + // Uno.SourceGeneration tasks do not execute this task properly. + writer.AppendLineInvariant("#if __WASM__"); + writer.AppendLineInvariant(_isWasm ? "" : "#error invalid internal source generator state. The __WASM__ DefineConstant was not propagated properly."); + writer.AppendLineInvariant("#endif"); + using (writer.BlockInvariant("namespace {0}", _defaultNamespace)) { writer.AppendLineInvariant("/// "); diff --git a/src/Uno.UI.Runtime.Skia.Gtk/buildTransitive/Uno.UI.Runtime.Skia.Gtk.targets b/src/Uno.UI.Runtime.Skia.Gtk/buildTransitive/Uno.UI.Runtime.Skia.Gtk.targets index 41a43c45e958..ff1054fdcf53 100644 --- a/src/Uno.UI.Runtime.Skia.Gtk/buildTransitive/Uno.UI.Runtime.Skia.Gtk.targets +++ b/src/Uno.UI.Runtime.Skia.Gtk/buildTransitive/Uno.UI.Runtime.Skia.Gtk.targets @@ -5,7 +5,7 @@ + BeforeTargets="PrepareForBuild"> $(UnoDefineConstants);UNO_REFERENCE_API;HAS_UNO_SKIA;HAS_UNO_SKIA_GTK diff --git a/src/Uno.UI.Runtime.Skia.Tizen/buildTransitive/Uno.UI.Runtime.Skia.Tizen.targets b/src/Uno.UI.Runtime.Skia.Tizen/buildTransitive/Uno.UI.Runtime.Skia.Tizen.targets index d2b5d40d14bf..638bb7c4f74e 100644 --- a/src/Uno.UI.Runtime.Skia.Tizen/buildTransitive/Uno.UI.Runtime.Skia.Tizen.targets +++ b/src/Uno.UI.Runtime.Skia.Tizen/buildTransitive/Uno.UI.Runtime.Skia.Tizen.targets @@ -5,7 +5,7 @@ + BeforeTargets="PrepareForBuild"> $(UnoDefineConstants);UNO_REFERENCE_API;HAS_UNO_SKIA;HAS_UNO_SKIA_TIZEN diff --git a/src/Uno.UI.Runtime.Skia.Wpf/buildTransitive/Uno.UI.Runtime.Skia.Wpf.targets b/src/Uno.UI.Runtime.Skia.Wpf/buildTransitive/Uno.UI.Runtime.Skia.Wpf.targets index 9eed6c3aabee..bc2879ee8c0d 100644 --- a/src/Uno.UI.Runtime.Skia.Wpf/buildTransitive/Uno.UI.Runtime.Skia.Wpf.targets +++ b/src/Uno.UI.Runtime.Skia.Wpf/buildTransitive/Uno.UI.Runtime.Skia.Wpf.targets @@ -2,7 +2,7 @@ + BeforeTargets="PrepareForBuild"> $(UnoDefineConstants);UNO_REFERENCE_API;HAS_UNO_SKIA;HAS_UNO_SKIA_WPF diff --git a/src/Uno.UI.Runtime.WebAssembly/buildTransitive/Uno.UI.Runtime.WebAssembly.targets b/src/Uno.UI.Runtime.WebAssembly/buildTransitive/Uno.UI.Runtime.WebAssembly.targets index 8f582791b035..c34be8c031a0 100644 --- a/src/Uno.UI.Runtime.WebAssembly/buildTransitive/Uno.UI.Runtime.WebAssembly.targets +++ b/src/Uno.UI.Runtime.WebAssembly/buildTransitive/Uno.UI.Runtime.WebAssembly.targets @@ -5,7 +5,7 @@ + BeforeTargets="PrepareForBuild"> $(UnoDefineConstants);UNO_REFERENCE_API;HAS_UNO_WASM;__WASM__