Skip to content

Commit

Permalink
Merge pull request #306 from unoplatform/mergify/bp/release/stable/1.…
Browse files Browse the repository at this point in the history
…5/pr-305

fix: Override WasmPWAManifestFile properly (backport #305)
  • Loading branch information
jeromelaban authored Jul 16, 2024
2 parents 3da781d + c136de1 commit 0ec1242
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@
<_ResizetizerSplashScreenPath>$(_UnoIntermediateImages)splash_screen.scale-300.png</_ResizetizerSplashScreenPath>
<_ResizetizerAppIconPath>$(_UnoIntermediateAppIcon)favicon.ico</_ResizetizerAppIconPath>
<_ResizetizerAppIconImagesPath>$(_UnoIntermediateAppIcon)iconapp-128.png</_ResizetizerAppIconImagesPath>
<_ResizetizerUnoManifestJson>$(_UnoIntermediateAppIcon)Unomanifest.webmanifest</_ResizetizerUnoManifestJson>
<_ResizetizerUnoManifestJson>$(_UnoIntermediateAppIcon)..\manifest.webmanifest</_ResizetizerUnoManifestJson>
<_ResizetizerImagesNestedPath>$(_UnoIntermediateImages)MyAssets\Nested\dotnet_bot.scale-300.png</_ResizetizerImagesNestedPath>
<_ResizetizerImagesPath>$(_UnoIntermediateImages)Assets\Images\dotnet_bot2.scale-300.png</_ResizetizerImagesPath>
</PropertyGroup>
<Message Text="Validating local assets at '$(_ResizetizerIntermediateOutputRoot)'" Importance="high" />
<Error Condition="!Exists('$(_ResizetizerSplashScreenPath)')" Text="SplashScreen file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerAppIconPath)')" Text=".ico file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerAppIconImagesPath)')" Text="App icon image file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerUnoManifestJson)')" Text="Unomanifest.json file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerUnoManifestJson)')" Text="manifest.json file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerImagesNestedPath)')" Text="images file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerImagesPath)')" Text="images file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerManifestPath)')" Text="Manifest file wasn't created." />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@
<_ResizetizerSplashScreenPath>$(_UnoIntermediateImages)splash_screen.scale-300.png</_ResizetizerSplashScreenPath>
<_ResizetizerAppIconPath>$(_UnoIntermediateAppIcon)favicon.ico</_ResizetizerAppIconPath>
<_ResizetizerAppIconImagesPath>$(_UnoIntermediateAppIcon)iconapp-128.png</_ResizetizerAppIconImagesPath>
<_ResizetizerUnoManifestJson>$(_UnoIntermediateAppIcon)Unomanifest.webmanifest</_ResizetizerUnoManifestJson>
<_ResizetizerUnoManifestJson>$(_UnoIntermediateAppIcon)..\manifest.webmanifest</_ResizetizerUnoManifestJson>
</PropertyGroup>
<Message Text="Validating local assets at '$(_UnoIntermediateImages)'" Importance="high" />
<Error Condition="!Exists('$(_ResizetizerManifestPath)')" Text="Manifest file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerSplashScreenPath)')" Text="SplashScreen file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerAppIconPath)')" Text=".ico file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerAppIconImagesPath)')" Text="App icon image file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerUnoManifestJson)')" Text="Unomanifest.webmanifest file wasn't created." />
<Error Condition="!Exists('$(_ResizetizerUnoManifestJson)')" Text="manifest.webmanifest file wasn't created." />
</Target>
</Project>
9 changes: 5 additions & 4 deletions src/.nuspec/Uno.Resizetizer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,16 @@
<_UnoResizetizerCollectedImages Condition="'@(CopiedResources)' == ''" Include="$(_UnoIntermediateImages)**\*"/>
<_UnoResizetizerCollectedAppIcons Include="$(_UnoIntermediateAppIcon)**\*"/>

<!-- If the PWA manifest is empty we can try to find it on the disk -->
<_UnoUnoResizetizerPwaManifestItemGroup Condition="'$(UnoResizetizerPwaManifest)' ==''" Include="$(_UnoIntermediateAppIcon)**\*.json"/>
<!-- If the AppIcon property is empty we can try to find it on the disk -->
<_AppIconItemGroup Condition="'$(AppIconPath)' == ''" Include="$(_UnoResizetizerIntermediateOutputRoot)**\*.ico"/>
</ItemGroup>

<PropertyGroup>
<!-- If the PWA manifest is empty we can try to find it on the disk -->
<UnoResizetizerPwaManifest Condition="'$(UnoResizetizerPwaManifest)' ==''">%(_UnoUnoResizetizerPwaManifestItemGroup.FullPath)</UnoResizetizerPwaManifest>
<!-- If the PWA manifest is empty we can try to find it on disk -->
<_UnoResizetizerPwaManifest>$(_UnoIntermediateAppIcon)..\$([System.IO.Path]::GetFileName($(WasmPWAManifestFile)))</_UnoResizetizerPwaManifest>
<UnoResizetizerPwaManifest Condition="
'$(UnoResizetizerPwaManifest)'=='' and
Exists('$(_UnoResizetizerPwaManifest)')">$(_UnoResizetizerPwaManifest)</UnoResizetizerPwaManifest>
<!-- If the AppIcon property is empty we can try to find it on the disk -->
<AppIconPath Condition="'$(AppIconPath)' == ''">%(_AppIconItemGroup.Identity)</AppIconPath>
</PropertyGroup>
Expand Down
13 changes: 4 additions & 9 deletions src/.nuspec/Uno.Resizetizer.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
Condition="'$(DesignTimeBuild)' != 'true'">

<!-- Wasm -->
<PropertyGroup>
<WasmPWAManifestFile Condition="'$(UnoResizetizerPwaManifest)'!=''">$(UnoResizetizerPwaManifest)</WasmPWAManifestFile>
</PropertyGroup>

<ItemGroup>
<Content Include="@(_UnoResizetizerCollectedImages->FullPath())"
Link="%(_UnoResizetizerCollectedImages.RecursiveDir)%(_UnoResizetizerCollectedImages.Filename)%(_UnoResizetizerCollectedImages.Extension)">
Expand All @@ -64,14 +68,5 @@

<FileWrites Include="@(_UnoResizetizerCollectedImages)"/>
</ItemGroup>

<ItemGroup Condition="'$(UnoResizetizerPwaManifest)' != ''">
<Content Remove="$(WasmPWAManifestFile)"/>
<Content Include="$(UnoResizetizerPwaManifest)"
CopyToOutputDirectory="PreserveNewest"
ExcludeFromSingleFile="True"
CopyToPublishDirectory="PreserveNewest"
Link="$(WasmPWAManifestFile)"/>
</ItemGroup>
</Target>
</Project>
4 changes: 2 additions & 2 deletions src/Resizetizer/src/ResizetizeImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ResizetizeImages_v0 : UnoAsyncTask, ILogger
public ITaskItem[] AndroidAppIcons { get; set; }

[Output]
public ITaskItem PwaGeneratedManifestPath { get; set; }
public string PwaGeneratedManifestPath { get; set; }

public string IsMacEnabled { get; set; }

Expand Down Expand Up @@ -212,7 +212,7 @@ void ProcessAppIcon(ResizeImageInfo img, ConcurrentBag<ResizedImageInfo> resized

var icon = wasmIconGen.Generate();
var manifestPath = wasmIconGen.ProcessThePwaManifest();
PwaGeneratedManifestPath = new TaskItem(manifestPath);
PwaGeneratedManifestPath = manifestPath;

string itemSpec = Path.GetFullPath(icon.Filename);
GeneratedIconPath = new TaskItem(itemSpec);
Expand Down
6 changes: 4 additions & 2 deletions src/Resizetizer/src/WasmIconGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ public string ProcessThePwaManifest()
};

Logger.Log("Writing the PWA manifest with the icons property.");
var newPwaManifestName = "Uno" + Path.GetFileName(pwaManifestPath);
var outputPath = Path.Combine(IntermediateOutputPath, newPwaManifestName);

var outputPath = Path.Combine(
Path.GetDirectoryName(Path.GetDirectoryName(IntermediateOutputPath)),
Path.GetFileName(pwaManifestPath));

using var fs = File.Create(outputPath);
using var writer = new Utf8JsonWriter(fs, writeOptions);
Expand Down

0 comments on commit 0ec1242

Please sign in to comment.