Skip to content

Commit

Permalink
Handle content hiding separately for hot restart scenarios (#6341)
Browse files Browse the repository at this point in the history
  • Loading branch information
captainsafia authored Apr 26, 2022
1 parent c785ec6 commit 578d6ed
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</Target>

<!-- Targets temporarily remove Content items in various folders so that they don't conflict with iOS/MacCatalyst SDK tasks -->
<Target Name="HideContentFromiOSBundleResources" BeforeTargets="_CollectBundleResources;_CollectHotRestartBundleResources">
<Target Name="HideContentFromiOSBundleResources" BeforeTargets="_CollectBundleResources">
<ItemGroup>
<!-- Find all files outside the wwwroot folder -->
<_NonWWWRootContent Include="@(Content)" Exclude="wwwroot/**/*" />
Expand All @@ -71,9 +71,28 @@
<Content Remove="@(_TemporaryHiddenContent)" />
</ItemGroup>
</Target>
<Target Name="RestoreHiddeniOSContent" AfterTargets="_CollectBundleResources" BeforeTargets="ResolveCurrentProjectStaticWebAssetsInputs">
<ItemGroup>
<!-- Restore the previously removed Content items -->
<Content Include="@(_TemporaryHiddenContent)" />
</ItemGroup>
</Target>

<!-- Restore hidden Content items for iOS/MacCatalyst -->
<Target Name="RestoreHiddeniOSContent" AfterTargets="_CollectBundleResources;_CollectHotRestartBundleResources" BeforeTargets="ResolveCurrentProjectStaticWebAssetsInputs">
<!-- Handle hiding and restoring <Content /> from the iOS build in hot reload scenarios. -->
<Target Name="HideContentFromiOSHotRestartBundleResources" BeforeTargets="_CollectHotRestartBundleResources">
<ItemGroup>
<!-- Find all files outside the wwwroot folder -->
<_NonWWWRootContent Include="@(Content)" Exclude="wwwroot/**/*" />
<!-- Create a list of all content that *is* in the wwwroot folder (to preserve ItemGroup metadata) -->
<_TemporaryHiddenContent Include="@(Content)" Exclude="@(_NonWWWRootContent)" />
<!-- Add Scoped CSS files in the app to the list of hidden items -->
<_TemporaryHiddenContent Include="Pages\**\*.razor.css" />
<_TemporaryHiddenContent Include="Shared\**\*.razor.css" />
<!-- Temporarily remove the items -->
<Content Remove="@(_TemporaryHiddenContent)" />
</ItemGroup>
</Target>
<Target Name="RestoreHiddeniOSHotRestartContent" AfterTargets="_CollectHotRestartBundleResources" BeforeTargets="ResolveCurrentProjectStaticWebAssetsInputs">
<ItemGroup>
<!-- Restore the previously removed Content items -->
<Content Include="@(_TemporaryHiddenContent)" />
Expand Down

0 comments on commit 578d6ed

Please sign in to comment.