Skip to content

Commit

Permalink
Merge pull request #19339 from unoplatform/dev/dr/hrUpdates
Browse files Browse the repository at this point in the history
fix(hr): Fix HR not working on android with Rider
  • Loading branch information
jeromelaban authored Jan 27, 2025
2 parents 277af47 + d652099 commit 690d566
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
<CompilerVisibleProperty Include="UnoRemoteControlProcessorsPath" />
<CompilerVisibleProperty Include="UnoRemoteControlConfigCookie" />
<CompilerVisibleProperty Include="UnoHotReloadDiagnosticsLogPath" />
<CompilerVisibleProperty Include="AppendRuntimeIdentifierToOutputPath" />
<CompilerVisibleProperty Include="OutputPath" />
<CompilerVisibleProperty Include="UnoDisableBindableTypeProvidersGeneration" />
<CompilerVisibleProperty Include="ShouldWriteErrorOnInvalidXaml" />
<CompilerVisibleProperty Include="IsUiAutomationMappingEnabled" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class RemoteControlGenerator : ISourceGenerator
"DevEnvDir",
"MSBuildVersion",
"UnoHotReloadDiagnosticsLogPath",
"AppendRuntimeIdentifierToOutputPath",
"OutputPath"
};

public void Initialize(GeneratorInitializationContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,25 @@ private void InitializeInner(ConfigureServer configureServer)
// props/items in the context of the hot reload workspace.
properties["UnoIsHotReloadHost"] = "True";

// Set the RuntimeIdentifier as a temporary property so that we do not force the
// property as a read-only global property that would be transitively applied to
// projects that are not supporting the head's RuntimeIdentifier. (e.g. an android app
// which references a netstd2.0 library project)
// If the runtime identifier NOT been used in the output path, this usually indicates that it was not passed as a parameter for the build
// in that case we **must** not use it to init the hot-reload workspace (parameters are required to be exactly the same to get valid patches)
// Note: This is required to get HR to work on Rider 2024.3 with Android
// Note 2: We remove both properties to make sure to use the default behavior
var appendIdToPath = properties.Remove("AppendRuntimeIdentifierToOutputPath", out var appendStr)
&& bool.TryParse(appendStr, out var append)
&& append;
var hasOutputPath = properties.Remove("OutputPath", out var outputPath);

if (properties.Remove("RuntimeIdentifier", out var runtimeIdentifier))
{
properties["UnoHotReloadRuntimeIdentifier"] = runtimeIdentifier;
if (appendIdToPath && hasOutputPath && Path.TrimEndingDirectorySeparator(outputPath ?? "").EndsWith(runtimeIdentifier, StringComparison.OrdinalIgnoreCase))
{
// Set the RuntimeIdentifier as a temporary property so that we do not force the
// property as a read-only global property that would be transitively applied to
// projects that are not supporting the head's RuntimeIdentifier. (e.g. an android app
// which references a netstd2.0 library project)
properties["UnoHotReloadRuntimeIdentifier"] = runtimeIdentifier;
}
}

var result = await CompilationWorkspaceProvider.CreateWorkspaceAsync(
Expand Down

0 comments on commit 690d566

Please sign in to comment.