diff --git a/docs/building-apps/build-properties.md b/docs/building-apps/build-properties.md
index e6e264ecad6..22f1b29f4fb 100644
--- a/docs/building-apps/build-properties.md
+++ b/docs/building-apps/build-properties.md
@@ -676,7 +676,9 @@ assemblies so they stay byte-for-byte unchanged (a requirement for Hot
Reload). This will disable a few minor optimizations, but will otherwies not
affect anything.
-The default value is `true` for debug builds and `false` otherwise.
+The default value is `true` for non-NativeAOT debug builds that don't use the
+managed static registrar, and `false` otherwise (the managed static registrar
+modifies user assemblies, which is incompatible with Hot Reload).
## IBToolPath
diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets
index 78fce49117f..9a6452cf8ff 100644
--- a/dotnet/targets/Xamarin.Shared.Sdk.targets
+++ b/dotnet/targets/Xamarin.Shared.Sdk.targets
@@ -123,14 +123,6 @@
<_BundlerDebug Condition="'$(_BundlerDebug)' == ''">false
-
- $(_BundlerDebug)
-
$(_BundlerDebug)
@@ -651,7 +643,21 @@
-
+
+
+
+ false
+ $(_BundlerDebug)
+ false
+
+
+
+
@@ -665,6 +671,14 @@
<_UseDynamicDependenciesInsteadOfMarking Condition="'$(_UseDynamicDependenciesInsteadOfMarking)' == ''">true
<_UseDynamicDependenciesForProtocolPreservation Condition="'$(_UseDynamicDependenciesForProtocolPreservation)' == ''">$(_UseDynamicDependenciesInsteadOfMarking)
+
+ <_UseDynamicDependenciesForSmartEnumPreservation Condition="'$(_UseDynamicDependenciesForSmartEnumPreservation)' == '' And '$(HotReloadCompatibleBuild)' == 'true' And '$(PrepareAssemblies)' != 'true'">false
<_UseDynamicDependenciesForSmartEnumPreservation Condition="'$(_UseDynamicDependenciesForSmartEnumPreservation)' == ''">$(_UseDynamicDependenciesInsteadOfMarking)
<_UseDynamicDependenciesForBlockCodePreservation Condition="'$(_UseDynamicDependenciesForBlockCodePreservation)' == ''">$(_UseDynamicDependenciesInsteadOfMarking)
<_UseDynamicDependenciesForGeneratedCodeOptimizations Condition="'$(_UseDynamicDependenciesForGeneratedCodeOptimizations)' == ''">$(_UseDynamicDependenciesInsteadOfMarking)
diff --git a/tests/common/shared-dotnet.csproj b/tests/common/shared-dotnet.csproj
index b6da56214c9..ca1e6ada0a9 100644
--- a/tests/common/shared-dotnet.csproj
+++ b/tests/common/shared-dotnet.csproj
@@ -132,12 +132,25 @@
happen in a target (and not in a plain PropertyGroup), because $(HotReloadCompatibleBuild)
is computed in the platform SDK targets, which are imported after this file.
-->
-
-
+
+
$(DefineConstants);HOTRELOAD_COMPATIBLE_BUILD
+
+
+
+
+
+
+
diff --git a/tools/dotnet-linker/AppBundleRewriter.cs b/tools/dotnet-linker/AppBundleRewriter.cs
index a6d545837ac..c2ccd6fe06e 100644
--- a/tools/dotnet-linker/AppBundleRewriter.cs
+++ b/tools/dotnet-linker/AppBundleRewriter.cs
@@ -1501,9 +1501,13 @@ void SaveAssembly (AssemblyDefinition assembly)
{
if (assembly != CurrentAssembly && assembly != PlatformAssembly)
throw new InvalidOperationException ($"Can't save assembly {assembly.Name} because it's not the current assembly ({CurrentAssembly.Name}) or the platform assembly ({PlatformAssembly.Name}).");
- AssemblySaved?.Invoke (assembly);
var annotations = configuration.Context.Annotations;
var action = annotations.GetAction (assembly);
+ if (configuration.HotReloadCompatibleBuild && action == AssemblyAction.Copy && assembly != PlatformAssembly) {
+ configuration.Logger.LogError (ErrorHelper.CreateError (99, $"The assembly '{assembly.Name.Name}' is reloadable, but was modified during a Hot Reload compatible build."));
+ return;
+ }
+ AssemblySaved?.Invoke (assembly);
if (action == AssemblyAction.Copy) {
#if !ASSEMBLY_PREPARER
// Preserve TypeForwardedTo which would the linker sweep otherwise