Skip to content

Commit

Permalink
feat: Add ability to configure hot reload engine also in release
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Oct 18, 2023
1 parent fe2dea4 commit 4e0ad7a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
{
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<UnoRuntimeEnabledPackage Include="Uno.WinUI.DevServer" PackageBasePath="$(MSBuildThisFileDirectory)" Condition="'$(MSBuildThisFile)'=='uno.winui.devserver.targets'" />
</ItemGroup>

<ItemGroup>
<CompilerVisibleProperty Include="UnoDevServer_IncludeProjectConfiguration" />
<CompilerVisibleProperty Include="UnoDevServer_IncludeServerProcessorsConfiguration" />
</ItemGroup>

<PropertyGroup>
<!-- Keep the inner path with '/' separator -->
<UnoRemoteControlProcessorsPath Condition="'$(SolutionFileName)'!='Uno.UI.sln'">$(MSBuildThisFileDirectory)../tools/rc/processors</UnoRemoteControlProcessorsPath>
Expand All @@ -20,7 +25,6 @@
<_UnoRCHostVersionPath Condition="'$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework)))' &gt; 7">net8.0</_UnoRCHostVersionPath>
</PropertyGroup>


<Message Text="&lt;RemoteControlHostPath&gt;$(MSBuildThisFileDirectory)../tools/rc/host/$(_UnoRCHostVersionPath)/Uno.UI.RemoteControl.Host.dll&lt;/RemoteControlHostPath&gt;" Importance="High" />
<Message Text="&lt;IntermediateOutputPath&gt;$(MSBuildProjectDirectory)/$(IntermediateOutputPath)&lt;/IntermediateOutputPath&gt;" Importance="High" />
<Message Text="&lt;IsRCClientRemote&gt;$(_IsRCClientRemote)&lt;/IsRCClientRemote&gt;" Importance="High" />
Expand Down

0 comments on commit 4e0ad7a

Please sign in to comment.