Skip to content

Commit

Permalink
Wire up build targets to exclude content items from iOS and Android c…
Browse files Browse the repository at this point in the history
…hecks (dotnet#4861)

* Wire up build targets to exclude content items from iOS and Android checks

Fixes dotnet#3014
  • Loading branch information
pranavkm authored Feb 24, 2022
1 parent 74f7584 commit 2b568a4
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,38 @@
<RazorComponent Include="**\*.razor" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<ItemGroup>
<!--
Web assets (js, css, etc under wwwroot) and .razor files are represented as Content items in the Razor SDK, but run foul of
checks in the Android and iOS SDK. This annotates these items with metadata that prevents them from being bundled / examined.
-->
<Content Update="@(Content->WithMetadataValue('WebContentItem', 'true'))"
ExcludeFromContentCheck="true"
PublishFolderType="None" />

<Content Update="@(Content->WithMetadataValue('Extension', '.razor'))"
ExcludeFromContentCheck="true"
PublishFolderType="None" />
</ItemGroup>

<PropertyGroup>
<StaticWebAssetBasePath>/</StaticWebAssetBasePath>
<StaticWebAssetProjectMode>Root</StaticWebAssetProjectMode>
</PropertyGroup>

<Target Name="ConvertStaticWebAssetsToMauiAssets" BeforeTargets="GetMauiItems;ResizetizeCollectItems" DependsOnTargets="ResolveProjectReferences;StaticWebAssetsPrepareForRun;StaticWebAssetsPrepareForPublish;LoadStaticWebAssetsPublishManifest">
<Target Name="ConvertStaticWebAssetsToMauiAssets"
BeforeTargets="GetMauiItems;ResizetizeCollectItems;_CollectBundleResources;_CollectHotRestartBundleResources;_CheckForContent"
DependsOnTargets="ResolveProjectReferences;StaticWebAssetsPrepareForRun;StaticWebAssetsPrepareForPublish;LoadStaticWebAssetsPublishManifest">

<ComputeStaticWebAssetsTargetPaths Assets="@(StaticWebAsset)" PathPrefix="wwwroot">
<Output TaskParameter="AssetsWithTargetPath" ItemName="_MauiStaticWebAssetWithTargetPath" />
</ComputeStaticWebAssetsTargetPaths>

<ItemGroup>
<MauiAsset Include="%(_MauiStaticWebAssetWithTargetPath.Identity)">
<Link>%(_MauiStaticWebAssetWithTargetPath.TargetPath)</Link>
<TargetPath>%(_MauiStaticWebAssetWithTargetPath.TargetPath)</TargetPath>
</MauiAsset>
</ItemGroup>

<!-- Update Content files that are managed by the Razor SDK to opt out of iOS and Android content-checks -->
<ItemGroup>
<!-- .razor.css scoped css files -->
<_ContentNotScopedCssFiles Include="@(Content)" Exclude="@(ScopedCssInput)" />
<_ContentToUpdate Include="@(Content)" Exclude="@(_ContentNotScopedCssFiles)" />

<!-- .razor files -->
<_ContentToUpdate Include="@(Content->WithMetadataValue('Extension', '.razor'))" />

<Content Remove="@(_ContentToUpdate)" />
<Content Include="@(_ContentToUpdate)" ExcludeFromContentCheck="true" PublishFolderType="None" />
</ItemGroup>
</Target>

<!-- Targets temporarily remove Content items in various folders so that they don't conflict with iOS/MacCatalyst SDK tasks -->
Expand Down

0 comments on commit 2b568a4

Please sign in to comment.