Skip to content

Commit

Permalink
chore: Adjust publish items validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Nov 25, 2024
1 parent 9a216fb commit 9cbb229
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
-->
<UnoFeatures>
</UnoFeatures>

<NoWarn>$(NoWarn);NU1605;IL2026;IL2008;IL2104</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -49,7 +51,7 @@
</ItemGroup>

<Target Name="_UnoValidateSelfAssets"
BeforeTargets="AfterBuild">
BeforeTargets="AfterBuild" Condition=" $(_IsPublishing) != 'true' ">

<ItemGroup
Condition=" '$(TargetFramework)' == 'net9.0-windows10.0.19041' OR '$(TargetFramework)' == 'net9.0-desktop' ">
Expand All @@ -75,27 +77,88 @@

<ItemGroup
Condition="'$(TargetFramework)'=='net9.0-browserwasm'">
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\Assets\SharedAssets.md" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\Assets\json_file_asset.json" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\Assets\Icons\icon_foreground.png" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\Assets\Icons\icon_foreground.scale-100.png" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\Assets\Icons\icon_foreground.scale-125.png" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\Assets\Icons\icon_foreground.scale-150.png" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\Assets\Icons\icon_foreground.scale-200.png" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\Assets\Icons\icon_foreground.scale-300.png" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\Assets\Icons\icon_foreground.scale-400.png" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\Assets\SharedAssets.md" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\Assets\json_file_asset.json" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\Assets\Icons\icon_foreground.png" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\Assets\Icons\icon_foreground.scale-100.png" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\Assets\Icons\icon_foreground.scale-125.png" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\Assets\Icons\icon_foreground.scale-150.png" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\Assets\Icons\icon_foreground.scale-200.png" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\Assets\Icons\icon_foreground.scale-300.png" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\Assets\Icons\icon_foreground.scale-400.png" />

<!-- wwwroot -->
<_AssetsToValidate Include="$(OutputPath)wwwroot\..\staticwebapp.config.json" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\..\web.config" />

<!-- Validate json files handling -->
<_AssetsToValidate Include="$(OutputPath)wwwroot\test_root_asset.json" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\test_root_asset_not_included.json" MustNotExist="true" />

<!--
Transitive library asset are not included in the output folder, as they're referenced
in-place by `uno53AppWithLib.staticwebassets.runtime.json`
<_AssetsToValidate Include="$(OutputPath)wwwroot\uno53lib\Assets\uno53lib-test.xml" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\uno53lib\Assets\uno53lib_icon_lib.png" />
-->
</ItemGroup>

<Error Text="Missing asset %(_AssetsToValidate.Identity)"
Condition="'@(_AssetsToValidate)'!='' AND '%(_AssetsToValidate.MustNotExist)'!='true' AND !exists('%(_AssetsToValidate.Identity)')" />

<Error Text="Invalid existing asset %(_AssetsToValidate.Identity)"
Condition="'@(_AssetsToValidate)'!='' AND '%(_AssetsToValidate.MustNotExist)'=='true' AND exists('%(_AssetsToValidate.Identity)')" />

<!-- Validate assets file -->

<ItemGroup Condition="'$(TargetFramework)'=='net9.0-browserwasm'">
<_StaticAssetsToValidate Include="uno53lib-test.xml" />
<_StaticAssetsToValidate Include="uno53lib_icon_lib.png" />
</ItemGroup>

<ReadLinesFromFile
File="$(OutputPath)$(AssemblyName).staticwebassets.runtime.json" >
<Output
TaskParameter="Lines"
ItemName="StaticWebAssetsRuntimeLines"/>
</ReadLinesFromFile>

<PropertyGroup>
<StaticWebAssetsRuntimeContent>@(StaticWebAssetsRuntimeLines)</StaticWebAssetsRuntimeContent>
</PropertyGroup>

<Error Text="Missing static web asset %(_StaticAssetsToValidate.Identity)"
Condition="'@(_StaticAssetsToValidate)'!='' AND '%(_StaticAssetsToValidate.MustNotExist)'!='true' AND !$(StaticWebAssetsRuntimeContent.Contains('%(_StaticAssetsToValidate.Identity)'))" />

</Target>

<Target Name="_UnoValidateSelfPublishedAssets"
BeforeTargets="AfterPublish" Condition=" $(_IsPublishing) == 'true' ">

<ItemGroup
Condition="'$(TargetFramework)'=='net9.0-browserwasm'">
<_AssetsToValidate Include="$(PublishDir)wwwroot\Assets\SharedAssets.md" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\Assets\json_file_asset.json" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\Assets\Icons\icon_foreground.png" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\Assets\Icons\icon_foreground.scale-100.png" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\Assets\Icons\icon_foreground.scale-125.png" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\Assets\Icons\icon_foreground.scale-150.png" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\Assets\Icons\icon_foreground.scale-200.png" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\Assets\Icons\icon_foreground.scale-300.png" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\Assets\Icons\icon_foreground.scale-400.png" />

<!-- wwwroot -->
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\..\staticwebapp.config.json" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\..\web.config" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\staticwebapp.config.json" />
<_AssetsToValidate Include="$(OutputPath)wwwroot\web.config" />

<!-- Validate json files handling -->
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\test_root_asset.json" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\test_root_asset_not_included.json" MustNotExist="true" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\test_root_asset.json" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\test_root_asset_not_included.json" MustNotExist="true" />

<!-- Transitive library asset -->
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\uno53lib\Assets\test.xml" />
<_AssetsToValidate Include="$(WasmShellOutputPackagePath)\uno53lib\Assets\icon_lib.png" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\uno53lib\Assets\uno53lib-test.xml" />
<_AssetsToValidate Include="$(PublishDir)wwwroot\uno53lib\Assets\uno53lib_icon_lib.png" />
</ItemGroup>

<Error Text="Missing asset %(_AssetsToValidate.Identity)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Condition="'$(_IsUnoUISolution)'==''"
AssemblyFile="$(UnoUIMSBuildTasksPath)\Uno.UI.Tasks.v0.dll"
TaskName="Uno.UI.Tasks.Assets.ExpandPackageAssets_v0" />

<UsingTask
Condition="'$(_IsUnoUISolution)'!=''"
AssemblyFile="$(UnoUIMSBuildTasksPath)\Uno.UI.Tasks.v0.dll"
Expand All @@ -21,7 +21,7 @@
<!-- Generate Library Layout when generating NuGet packages -->
<PropertyGroup Condition="'$(UnoSkipLibraryLayout)' != 'true'">
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_UnoIncludeLibraryAssets</TargetsForTfmSpecificContentInPackage>

<UnoPriInitialPath>$(AssemblyName)</UnoPriInitialPath>
<ProjectUnoPriFileName Condition="'$(ProjectUnoPriFileName)' == '' and '$(UnoPriInitialPath)' != ''">$(UnoPriInitialPath).uprimarker</ProjectUnoPriFileName>
<ProjectUnoPriFullPath Condition="'$(ProjectUnoPriFullPath)' == ''">$(TargetDir)$(ProjectUnoPriFileName)</ProjectUnoPriFullPath>
Expand All @@ -35,7 +35,7 @@
AfterTargets="_UnoGeneratePriMarker"
DependsOnTargets="_DefineUnoPriProperties"
BeforeTargets="GetCopyToOutputDirectoryItems">

<ItemGroup Condition="exists('$(ProjectUnoPriFullPath)')">
<_AllChildProjectItemsWithTargetPath Include="$(ProjectUnoPriFullPath)">
<TargetPath>$(ProjectUnoPriFileName)</TargetPath>
Expand All @@ -45,7 +45,7 @@
</ItemGroup>

</Target>

<!--
Marker generation to ensure that assets are only copied for uno-enabled targets
Expand All @@ -56,14 +56,14 @@
Condition="'$(GenerateLibraryLayout)' == 'true' AND '$(SDKIdentifier)' != 'Windows'"
BeforeTargets="PrepareForRun;GenerateNuSpec"
DependsOnTargets="_DefineUnoPriProperties">

<WriteLinesToFile File="$(ProjectUnoPriFullPath)"
Lines="@(ContentWithTargetPath)"
Condition="'@(ContentWithTargetPath)'!=''"
Overwrite="true" />

</Target>

<!--
Assign NuGet metadata for generated nuget packages to contain
assets next to each target framework assemblies
Expand Down Expand Up @@ -126,7 +126,7 @@
<ExpandPackageAssets_v0 MarkerFiles="@(_UnoPriFiles)">
<Output TaskParameter="Assets" ItemName="_UnoAssetsFilesExpanded" />
</ExpandPackageAssets_v0>

<ItemGroup>
<_AllChildProjectItemsWithTargetPath Include="@(_UnoAssetsFilesExpanded)" KeepMetadata="TargetPath">
<TargetPath Condition="'$(PriInitialPath)' != ''">$(PriInitialPath)\%(_UnoAssetsFilesExpanded.TargetPath)</TargetPath>
Expand Down Expand Up @@ -207,6 +207,43 @@
</ItemGroup>
</Target>

<PropertyGroup>
<_UnoAddAssetsFilesToPublishDirectoryDependsOn>
ContentFilesProjectOutputGroup;
AssignTargetPaths;
_DefineUnoPriProperties;
$(_UnoAddAssetsFilesToPublishDirectoryDependsOn)
</_UnoAddAssetsFilesToPublishDirectoryDependsOn>
</PropertyGroup>

<!--
Target executed by every project onto its references to determine publish assets.
Since this target renames assets to include the project name, it must not be executed
on the project head.
-->
<Target Name="_UnoAddAssetsFilesToPublishDirectory"
DependsOnTargets="$(_UnoAddAssetsFilesToPublishDirectoryDependsOn)"
Condition="'$(IsUnoHead)'!='true' and '$(AndroidApplication)'!='true' and '$(ProjectTypeGuids)'==''"
BeforeTargets="GetCopyToPublishDirectoryItems">

<ItemGroup>
<!-- Explicit exclusion of the assets when building for a ASP.NET hosted server project -->
<_UnoBootstrapServerReference Include="@(PackageReference)" Condition="'%(Identity)'=='Uno.Wasm.Bootstrap.Server'" />
</ItemGroup>

<ItemGroup Condition="'@(_UnoBootstrapServerReference)'==''">
<_AllChildProjectPublishItemsWithTargetPath Include="@(ContentWithTargetPath)">
<!-- Update link metadata only if available, prefer TargetPath otherwise -->
<Link Condition="'%(ContentWithTargetPath.Link)' != ''">$(UnoPriInitialPath)$(_UnoDirectorySeparator)%(ContentWithTargetPath.Link)</Link>
<TargetPath Condition="'$(UnoPriInitialPath)' != ''">$(UnoPriInitialPath)$(_UnoDirectorySeparator)%(ContentWithTargetPath.TargetPath)</TargetPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</_AllChildProjectPublishItemsWithTargetPath>

<ContentWithTargetPath Remove="@(_AllChildProjectPublishItemsWithTargetPath)" />
</ItemGroup>
</Target>

<!--
Adjust support for build output for Uno.Wasm.Bootstrap, because earlier
versions (3.x) don't support TargetPath metadata.
Expand All @@ -229,21 +266,21 @@
<Target Name="_UnoAssetsGetCopyToPublishDirectory"
BeforeTargets="GetCopyToPublishDirectoryItems"
Condition=" '$(UsingMicrosoftNETSdkWebAssembly)' != 'true' ">
<ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="@(_TransitiveItemsToCopyToOutputDirectory)">
<TargetPath>%(TargetPath)</TargetPath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ContentWithTargetPath>
</ItemGroup>
</Target>

<PropertyGroup>
<UnoGenerateAssetsManifestDependsOn>
$(UnoGenerateAssetsManifestDependsOn);
_UnoAssetsGetCopyToPublishDirectoryItems
</UnoGenerateAssetsManifestDependsOn>
</PropertyGroup>

<!--
Ensure that project transitive references are copied to the publish directory, as well
as nuget packages content.
Expand All @@ -259,7 +296,7 @@
<Link>wwwroot/%(TargetPath)</Link>
<TargetPath></TargetPath>
</_UnoTransitiveItems>

<_UnoTransitiveItems Remove="@(StaticWebAsset)" Condition="'%(StaticWebAsset.Link)' == '%(_UnoTransitiveItems.Link)'" />
</ItemGroup>

Expand Down Expand Up @@ -308,9 +345,9 @@
Returns="@(UnoAllCopyToOutputItems)"
KeepDuplicateOutputs="false"
DependsOnTargets="AssignTargetPaths;AssignTargetPaths;_GetProjectReferenceTargetFrameworkProperties">

<PropertyGroup>
<_UnoGCKeepMetadata>CopyToPublishDirectory;ExcludeFromSingleFile;TargetPath</_UnoGCKeepMetadata>
<_UnoGCKeepMetadata>CopyToPublishDirectory;ExcludeFromSingleFile;TargetPath</_UnoGCKeepMetadata>
</PropertyGroup>

<MSBuild Projects="@(_MSBuildProjectReferenceExistent)"
Expand Down
9 changes: 0 additions & 9 deletions src/Uno.Sdk/targets/Uno.DefaultItems.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,30 @@
<!-- Include all images by default - matches the __WindowsAppSdkDefaultImageIncludes property in the WindowsAppSDK -->
<Content Include="$(AssetsFolder)**"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);**\*.svg;**\*.cs;@(Content)"
CopyToOutputDirectory="true"
IsDefaultItem="true" />
<Content Include="$(AssetsFolder)\**\Svg\**\*.svg"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);**\*.cs;@(Content)"
CopyToOutputDirectory="true"
IsDefaultItem="true" />
<Content Include="**\*.png"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Content)"
CopyToOutputDirectory="true"
IsDefaultItem="true" />
<Content Include="**\*.bmp"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Content)"
CopyToOutputDirectory="true"
IsDefaultItem="true" />
<Content Include="**\*.jpg"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Content)"
CopyToOutputDirectory="true"
IsDefaultItem="true" />
<Content Include="**\*.dds"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Content)"
CopyToOutputDirectory="true"
IsDefaultItem="true" />
<Content Include="**\*.tif"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Content)"
CopyToOutputDirectory="true"
IsDefaultItem="true" />
<Content Include="**\*.tga"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Content)"
CopyToOutputDirectory="true"
IsDefaultItem="true" />
<Content Include="**\*.gif"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Content)"
CopyToOutputDirectory="true"
IsDefaultItem="true" />
<Page Include="**\*.xaml"
Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(Page);App.xaml"
Expand Down

0 comments on commit 9cbb229

Please sign in to comment.