From 4e0ad7a2e5aff7dab3dbca9bc4a3a575be2f55de Mon Sep 17 00:00:00 2001 From: David Date: Tue, 17 Oct 2023 13:04:03 -0400 Subject: [PATCH] feat: Add ability to configure hot reload engine also in release --- .../RemoteControl/RemoteControlGenerator.cs | 26 +++++++++++++++++++ .../buildTransitive/Uno.UI.DevServer.targets | 6 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs index b5e4cc672faf..772abdf0b0de 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/RemoteControl/RemoteControlGenerator.cs @@ -53,6 +53,9 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { + var isProjectConfigEnabled = Is("UnoDevServer_IncludeProjectConfiguration"); + var isServerProcessorsConfigEnabled = Is("UnoDevServer_IncludeServerProcessorsConfiguration"); + if (!DesignTimeHelper.IsDesignTime(context) && context.GetMSBuildPropertyValue("Configuration") == "Debug") { @@ -85,6 +88,29 @@ public void Execute(GeneratorExecutionContext context) context.AddSource("RemoteControl", sb.ToString()); } } + else if (isProjectConfigEnabled || isServerProcessorsConfigEnabled) + { + // This is designed for runtime-tests that wants to test HotReload also in release (i.e. using app built on the CI). + // The runtime-test package will add those properties if the dev-server package is referenced so apps will be automatically + // configured properly as soon as they reference both the dev-server and the runtime-test package. + + var sb = new IndentedStringBuilder(); + BuildGeneratedFileHeader(sb); + + if (isProjectConfigEnabled) + { + BuildProjectConfiguration(context, sb); + } + if (isServerProcessorsConfigEnabled) + { + BuildServerProcessorsPaths(context, sb); + } + + context.AddSource("RemoteControl", sb.ToString()); + } + + bool Is(string propertyName) + => bool.TryParse(context.GetMSBuildPropertyValue(propertyName), out var value) && value; } private static bool IsInsideUnoSolution(GeneratorExecutionContext context) diff --git a/src/Uno.UI.RemoteControl/buildTransitive/Uno.UI.DevServer.targets b/src/Uno.UI.RemoteControl/buildTransitive/Uno.UI.DevServer.targets index a58b3b6c1e10..e582abec30cb 100644 --- a/src/Uno.UI.RemoteControl/buildTransitive/Uno.UI.DevServer.targets +++ b/src/Uno.UI.RemoteControl/buildTransitive/Uno.UI.DevServer.targets @@ -6,6 +6,11 @@ + + + + + $(MSBuildThisFileDirectory)../tools/rc/processors @@ -20,7 +25,6 @@ <_UnoRCHostVersionPath Condition="'$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework)))' > 7">net8.0 -