generated from unoplatform/template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Uno.Resizetizer.targets
678 lines (557 loc) · 30.1 KB
/
Uno.Resizetizer.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
<?xml version="1.0" encoding="UTF-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<AvailableItemName Include="UnoAsset" Exclude="@(AvailableItemName)" />
<AvailableItemName Include="UnoImage" Exclude="@(AvailableItemName)"/>
<AvailableItemName Include="UnoIcon" Exclude="@(AvailableItemName)"/>
<AvailableItemName Include="UnoSplashScreen" Exclude="@(AvailableItemName)"/>
</ItemGroup>
<PropertyGroup>
<_UnoResizetizerTaskAssemblyName>$(MSBuildThisFileDirectory)netstandard2.0\Uno.Resizetizer_v0.dll</_UnoResizetizerTaskAssemblyName>
</PropertyGroup>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.ResizetizeImages_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.DetectInvalidResourceOutputFilenamesTask_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.CreatePartialInfoPlistTask_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.GenerateSplashAndroidResources_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.GenerateSplashStoryboard_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.GenerateSplashAssets_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.GetUnoAssetPath_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.GeneratePackageAppxManifest_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.GenerateWasmSplashAssets_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.WindowIconGeneratorTask_V0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.CleanupAssetsTask_v0"/>
<UsingTask
AssemblyFile="$(_UnoResizetizerTaskAssemblyName)"
TaskName="Uno.Resizetizer.RemoveSvgFromContentTask_v0"/>
<PropertyGroup>
<CleanDependsOn>
$(CleanDependsOn);
_CleanUnoResizetizer;
</CleanDependsOn>
<_UnoResizetizerInputsFile>$(IntermediateOutputPath)UnoImage.inputs</_UnoResizetizerInputsFile>
<_UnoResizetizerStampFile>$(IntermediateOutputPath)UnoImage.stamp</_UnoResizetizerStampFile>
<_UnoSplashInputsFile>$(IntermediateOutputPath)Unosplash.inputs</_UnoSplashInputsFile>
<_UnoSplashStampFile>$(IntermediateOutputPath)Unosplash.stamp</_UnoSplashStampFile>
<_UnoManifestStampFile>$(IntermediateOutputPath)Unomanifest.stamp</_UnoManifestStampFile>
<_UnoResizetizerIntermediateOutputRoot>$(IntermediateOutputPath)unoresizetizer\</_UnoResizetizerIntermediateOutputRoot>
<_UnoIntermediateImages>$(_UnoResizetizerIntermediateOutputRoot)r\</_UnoIntermediateImages>
<_UnoIntermediateAppIcon>$(_UnoResizetizerIntermediateOutputRoot)AppIcons\</_UnoIntermediateAppIcon>
<_UnoIntermediateSplashScreen>$(_UnoResizetizerIntermediateOutputRoot)sp\</_UnoIntermediateSplashScreen>
<_UnoIntermediateManifest>$(_UnoResizetizerIntermediateOutputRoot)m\</_UnoIntermediateManifest>
<_UnoIntermediateStoryboard>$(_UnoIntermediateSplashScreen)UnoSplash.storyboard</_UnoIntermediateStoryboard>
<_UnoIntermediateAppManifestWasm>$(_UnoIntermediateSplashScreen)UnoAppManifest.js</_UnoIntermediateAppManifestWasm>
<_UnoResizetizerPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</_UnoResizetizerPlatformIdentifier>
<_UnoResizetizerNoTargetPlatform Condition="'$(_UnoResizetizerPlatformIdentifier)' == ''">True</_UnoResizetizerNoTargetPlatform>
<_UnoResizetizerPlatformIsAndroid Condition="'$(_UnoResizetizerPlatformIdentifier)' == 'android'">True</_UnoResizetizerPlatformIsAndroid>
<_UnoResizetizerPlatformIsiOS Condition="'$(_UnoResizetizerPlatformIdentifier)' == 'ios'">True</_UnoResizetizerPlatformIsiOS>
<_UnoResizetizerPlatformIsMacCatalyst Condition="'$(_UnoResizetizerPlatformIdentifier)' == 'maccatalyst'">True</_UnoResizetizerPlatformIsMacCatalyst>
<_UnoResizetizerPlatformIsmacOS Condition="'$(_UnoResizetizerPlatformIdentifier)' == 'macos'">True</_UnoResizetizerPlatformIsmacOS>
<_UnoResizetizerPlatformIstvOS Condition="'$(_UnoResizetizerPlatformIdentifier)' == 'tvos'">True</_UnoResizetizerPlatformIstvOS>
<_UnoResizetizerPlatformIsWindows Condition="$(_UnoResizetizerPlatformIdentifier.Contains('windows')) == 'True'">True</_UnoResizetizerPlatformIsWindows>
<UnoResizetizerIncludeSelfProject Condition="'$(UnoResizetizerIncludeSelfProject)' == ''">False</UnoResizetizerIncludeSelfProject>
<_UnoResizetizerDefaultInvalidFilenamesErrorMessage>One or more invalid file names were detected. File names must be lowercase, start and end with a letter character, and contain only alphanumeric characters or underscores:</_UnoResizetizerDefaultInvalidFilenamesErrorMessage>
<_WasmHasPWAManifest>False</_WasmHasPWAManifest>
<_WasmHasPWAManifest Condition="'$(WasmPWAManifestFile)' != ''">True</_WasmHasPWAManifest>
<_WasmPwaManifestPath Condition="'$(_WasmHasPWAManifest)' == 'True'">$(MSBuildProjectDirectory)\$(WasmPWAManifestFile)</_WasmPwaManifestPath>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<_UnoResizetizerIsNetCore>True</_UnoResizetizerIsNetCore>
<_UnoResizetizerIsSkiaApp Condition="'$(UnoRuntimeIdentifier)' == 'Skia' Or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'desktop'">True</_UnoResizetizerIsSkiaApp>
<_UnoResizetizerIsAndroidApp Condition=" '$(_UnoResizetizerPlatformIsAndroid)' == 'True' And '$(AndroidApplication)' == 'True'">True</_UnoResizetizerIsAndroidApp>
<_UnoResizetizerIsiOSApp Condition="( '$(_UnoResizetizerPlatformIsiOS)' == 'True' OR '$(_UnoResizetizerPlatformIsMacCatalyst)' == 'True' ) And ('$(OutputType)' == 'Exe' Or '$(IsAppExtension)' == 'True')">True</_UnoResizetizerIsiOSApp>
<_UnoResizetizerIsWindowsAppSdk Condition="('$(ProjectReunionWinUI)'=='True' Or '$(WindowsAppSDKWinUI)'=='true' or '$(UseWinUITools)'=='true') And '$(_UnoResizetizerPlatformIsWindows)' == 'True' And ('$(OutputType)' == 'WinExe' Or '$(OutputType)' == 'Exe')">True</_UnoResizetizerIsWindowsAppSdk>
<_UnoResizetizerIsWasmApp Condition="'$(UnoRuntimeIdentifier)' == 'WebAssembly' Or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'browserwasm'">True</_UnoResizetizerIsWasmApp>
</PropertyGroup>
<Import Project="Uno.Resizetizer.android.targets" Condition="'$(_UnoResizetizerIsAndroidApp)' == 'True'"/>
<Import Project="Uno.Resizetizer.wasm.targets" Condition="'$(_UnoResizetizerIsWasmApp)' == 'True'"/>
<Import Project="Uno.Resizetizer.apple.targets" Condition="'$(_UnoResizetizerIsiOSApp)' == 'True' Or '$(_UnoResizetizerPlatformIsMacCatalyst)' == 'True'"/>
<Import Project="Uno.Resizetizer.windows.skia.targets" Condition="'$(_UnoResizetizerIsWindowsAppSdk)' == 'True' Or '$(_UnoResizetizerIsSkiaApp)' == 'True'"/>
<PropertyGroup Condition="'$(_UnoResizetizerIsAndroidApp)' == 'True' Or '$(_UnoResizetizerIsiOSApp)' == 'True' Or '$(_UnoResizetizerIsSkiaApp)' == 'True' Or '$(_UnoResizetizerIsWindowsAppSdk)' == 'True' Or '$(_UnoResizetizerIsWasmApp)' == 'True'">
<_UnoResizetizerIsCompatibleApp>True</_UnoResizetizerIsCompatibleApp>
<UnoResizetizeDependsOnTargets>
$(UnoResizetizeDependsOnTargets);
UnoResizetizeCollectItems;
ProcessUnoSplashScreens;
</UnoResizetizeDependsOnTargets>
</PropertyGroup>
<PropertyGroup Condition="$(_UnoResizetizerNoTargetPlatform) == 'True' Or '$(_UnoResizetizerIsCompatibleApp)' != 'True'">
<UnoResizetizerIncludeSelfProject>true</UnoResizetizerIncludeSelfProject>
<UnoResizetizerPlatformType>netstandard</UnoResizetizerPlatformType>
<UnoResizetizeBeforeTargets>
$(UnoResizetizeBeforeTargets);
AssignTargetPaths;
</UnoResizetizeBeforeTargets>
<UnoResizetizeAfterTargets>
UnoResizetizeCollectItems;
$(UnoResizetizeAfterTargets);
UnoAssetsGeneration;
BuildDist;
</UnoResizetizeAfterTargets>
</PropertyGroup>
<!-- Skia -->
<PropertyGroup Condition="'$(_UnoResizetizerIsSkiaApp)' == 'True'">
<UnoResizetizerIncludeSelfProject>false</UnoResizetizerIncludeSelfProject>
<UnoResizetizeBeforeTargets>
UnoAssetsGeneration;
$(UnoResizetizeBeforeTargets);
AssignTargetPaths;
</UnoResizetizeBeforeTargets>
<UnoGeneratePackageAppxManifestDependsOnTargets>
$(UnoGeneratePackageAppxManifestDependsOnTargets);
UnoResizetizeCollectItems;
</UnoGeneratePackageAppxManifestDependsOnTargets>
<UnoGeneratePackageAppxManifestBeforeTargets>
$(UnoGeneratePackageAppxManifestDependsOnTargets);
SplitResourcesByCulture;
AssignTargetPaths;
</UnoGeneratePackageAppxManifestBeforeTargets>
</PropertyGroup>
<!-- Wasm -->
<PropertyGroup Condition="'$(_UnoResizetizerIsWasmApp)' == 'True'">
<UnoResizetizerPlatformType>wasm</UnoResizetizerPlatformType>
<UnoResizetizerIncludeSelfProject>false</UnoResizetizerIncludeSelfProject>
<UnoResizetizeBeforeTargets>
$(UnoResizetizeBeforeTargets);
AssignTargetPaths;
</UnoResizetizeBeforeTargets>
<UnoResizetizeAfterTargets>
UnoResizetizeCollectItems;
$(UnoResizetizeAfterTargets);
UnoAssetsGeneration;
BuildDist;
</UnoResizetizeAfterTargets>
</PropertyGroup>
<!-- iOS -->
<PropertyGroup Condition="'$(_UnoResizetizerIsiOSApp)' == 'True'">
<UnoResizetizerPlatformType>ios</UnoResizetizerPlatformType>
<!-- We don't want to resizetize anything for an inner build when building a universal app, it's enough to only do it in the outer build -->
<DisableUnoResizetizer Condition="'$(_IsMultiRidBuild)' == 'true'">true</DisableUnoResizetizer>
<UnoResizetizeBeforeTargets>
UnoAssetsGeneration;
_CollectBundleResources;
_BeforeCoreCompileImageAssets;
</UnoResizetizeBeforeTargets>
<CollectBundleResourcesDependsOn>
$(CollectBundleResourcesDependsOn);
UnoResizetizeCollectItems;
</CollectBundleResourcesDependsOn>
<CompileImageAssetsDependsOn>
$(CompileImageAssetsDependsOn);
UnoResizetizeCollectItems;
</CompileImageAssetsDependsOn>
<UnoResizetizeAfterTargets>
$(UnoResizetizeAfterTargets);
UnoResizetizeCollectItems;
</UnoResizetizeAfterTargets>
<CollectAppManifestsDependsOn>
ProcessUnoSplashScreens;
$(CollectAppManifestsDependsOn)
</CollectAppManifestsDependsOn>
</PropertyGroup>
<!-- Android -->
<PropertyGroup Condition="'$(_UnoResizetizerIsAndroidApp)' == 'True'">
<UnoResizetizerPlatformType>android</UnoResizetizerPlatformType>
<UnoResizetizeBeforeTargets>
UnoAssetsGeneration;
UnoResourcesGeneration;
$(UnoResizetizeBeforeTargets);
_GenerateAndroidResourceDir;
AssignTargetPaths;
</UnoResizetizeBeforeTargets>
<UnoResizetizeCollectItemsBeforeTargets>
_ComputeAndroidResourcePaths;
$(UnoResizetizeCollectItemsAfterTargets);
UnoAssetsGeneration;
</UnoResizetizeCollectItemsBeforeTargets>
<UnoResizetizeAfterTargets>
UnoResizetizeCollectItems;
$(UnoResizetizeAfterTargets);
UnoAssetsGeneration;
</UnoResizetizeAfterTargets>
</PropertyGroup>
<!-- UWP / WinUI -->
<PropertyGroup Condition="'$(_UnoResizetizerIsWindowsAppSdk)' == 'True'">
<UnoResizetizerPlatformType>uwp</UnoResizetizerPlatformType>
<UnoResizetizeBeforeTargets>
UnoAssetsGeneration;
$(UnoResizetizeBeforeTargets);
AssignTargetPaths;
</UnoResizetizeBeforeTargets>
<UnoGeneratePackageAppxManifestDependsOnTargets>
$(UnoGeneratePackageAppxManifestDependsOnTargets);
UnoResizetizeCollectItems;
</UnoGeneratePackageAppxManifestDependsOnTargets>
</PropertyGroup>
<!-- WPF/ SKIA -->
<PropertyGroup Condition="'$(_UnoResizetizerIsSkiaApp)' == 'True'">
<UnoResizetizerPlatformType>wpf</UnoResizetizerPlatformType>
<UnoResizetizeBeforeTargets>
$(UnoResizetizeBeforeTargets);
FileClassification;
</UnoResizetizeBeforeTargets>
</PropertyGroup>
<!-- Uno Icon -->
<ItemGroup>
<_WindowIconExtension Include="$(_UnoResizetizerIntermediateOutputRoot)Uno.Resizetizer.WindowIconExtensions.g.cs"/>
</ItemGroup>
<Target Name="ValidateAvailableItems"
BeforeTargets="UnoResizetizeCollectItems"
DependsOnTargets="_ResizetizerInitialize">
<Warning
Condition="'%(UnoIcon.Link)' != ''"
Text="The UnoIcon.Link property will be ignored."/>
<Warning
Condition="'@(UnoIcon->Count())' > '1'"
Text="More than one 'UnoIcon' is defined; only the first will be used." />
<Warning
Condition="'@(UnoSplashScreen->Count())' > '1'"
Text="More than one 'UnoSplashScreen' is defined; only the first will be used." />
<Warning
Condition="'%(UnoSplashScreen.Link)' != ''"
Text="The UnoSplashScreen.Link property will be ignored."/>
<Error
Condition="'@(UnoSplashScreen)' != '' And '@(UnoSplashScreen)' == '@(UnoIcon)'"
Text="The value of UnoSplashScreen and UnoIcon cannot be the same."/>
<Error
Condition="'@(UnoSplashScreen)' != '' And '@(UnoSplashScreen)' == '%(UnoIcon.ForegroundFile)'"
Text="The value of UnoSplashScreen and UnoIcon.ForegroundFile cannot be the same."/>
</Target>
<!-- Finds absolute paths to any UnoImage in this project -->
<!-- App head projects will invoke this target on their project references to collect images -->
<Target Name="GetUnoItems" Outputs="@(ExportedUnoItem)">
<ItemGroup>
<UnoItem Include="@(UnoImage)" ItemGroupName="UnoImage" Condition="'%(UnoImage.ForegroundFile)' == ''"/>
<UnoItem Include="@(UnoImage)" ItemGroupName="UnoImage" Condition="'%(UnoImage.ForegroundFile)' != ''" ForegroundFile="$([System.IO.Path]::GetFullPath('%(UnoImage.ForegroundFile)'))" ProjectDirectory="$(MSBuildProjectDirectory)"/>
<UnoItem Include="@(UnoIcon)" ItemGroupName="UnoIcon" Condition="'%(UnoIcon.ForegroundFile)' != ''" ForegroundFile="$([System.IO.Path]::GetFullPath('%(UnoIcon.ForegroundFile)'))"/>
<UnoItem Include="@(UnoAsset)" ItemGroupName="UnoAsset" ProjectDirectory="$(MSBuildProjectDirectory)"/>
<UnoItem Include="@(UnoSplashScreen)" ItemGroupName="UnoSplashScreen"/>
</ItemGroup>
<ConvertToAbsolutePath Paths="@(UnoItem)">
<Output TaskParameter="AbsolutePaths" ItemName="ExportedUnoItem"/>
</ConvertToAbsolutePath>
</Target>
<!--
This target is executed before Uno's assets generation task, which takes Content and generates
native assets. This way, UnoImage items are not duplicated in AndroidAssets or others, and only
generated assets are embedded in the app.
-->
<Target Name="_UnoResizetizer_CleanUpUnoImageFromContent"
BeforeTargets="UnoAssetsGeneration;_UnoAddAssetsFilesToCopyLocal">
<CleanupAssetsTask_v0 UnoImagesCollection="@(UnoImage)"
ContentCollection="@(ContentFilesProjectOutputGroupOutput)"
AndroidAssetCollection="@(AndroidAsset)">
<Output TaskParameter="ContentCollection" ItemName="ContentResult"/>
<Output TaskParameter="AndroidAssetCollection" ItemName="AndroidAssetResult"/>
<Output TaskParameter="RemovedFiles" ItemName="ItemsToNotIncludeOnContentFilesProjectOutputGroup"/>
</CleanupAssetsTask_v0>
<ItemGroup>
<ContentFilesProjectOutputGroupOutput Remove="@(ContentFilesProjectOutputGroupOutput)" />
<ContentFilesProjectOutputGroupOutput Include="@(ContentResult)" />
</ItemGroup>
<ItemGroup Condition="$(_UnoResizetizerPlatformIsAndroid) == 'true'">
<AndroidAsset Remove="@(AndroidAsset)"/>
<AndroidAsset Include="@(AndroidAssetResult)"/>
</ItemGroup>
</Target>
<!--
This target removes UnoImage processed content from transitive content propagation
when the head project enumerates content from its project references. This is needed
in order to avoid getting duplicate AndroidAssets.
-->
<Target Name="_UnoResizetizer_CleanUpContentFilesProjectOutputGroupOutput"
BeforeTargets="_UnoAddAssetsFilesToCopyLocal"
AfterTargets="ContentFilesProjectOutputGroup">
<RemoveSvgFromContentTask_v0 CollectionToRemove="@(ContentFilesProjectOutputGroupOutput)"
UnoImages="@(UnoImage)">
<Output TaskParameter="RemovedItems" ItemName="FinalResult"/>
</RemoveSvgFromContentTask_v0>
<ItemGroup>
<ContentFilesProjectOutputGroupOutput Remove="@(FinalResult)"/>
</ItemGroup>
</Target>
<!-- Collect images from referenced projects -->
<Target Name="UnoResizetizeCollectItems"
Condition="'$(_UnoResizetizerIsCompatibleApp)' == 'True' And '$(DisableUnoResizetizer)' != 'true'"
BeforeTargets="$(UnoResizetizeCollectItemsBeforeTargets)"
AfterTargets="$(UnoResizetizeCollectItemsAfterTargets)">
<CallTarget Targets="GetUnoItems" Condition="'$(UnoResizetizerIncludeSelfProject)' == 'True'">
<Output
TaskParameter="TargetOutputs"
ItemName="ImportedUnoItem"/>
</CallTarget>
<ItemGroup>
<UnoImage
Include="@(ImportedUnoItem)"
Condition="'%(ImportedUnoItem.ItemGroupName)' == 'UnoImage'"/>
<UnoIcon
Include="@(ImportedUnoItem)"
Condition="'%(ImportedUnoItem.ItemGroupName)' == 'UnoIcon'"/>
<UnoAsset
Include="@(ImportedUnoItem)"
Condition="'%(ImportedUnoItem.ItemGroupName)' == 'UnoAsset'"/>
<UnoSplashScreen
Include="@(ImportedUnoItem)"
Condition="'%(ImportedUnoItem.ItemGroupName)' == 'UnoSplashScreen'"/>
</ItemGroup>
<!-- Make sure animated gifs are not resized by default -->
<ItemGroup>
<UnoImage Update="@(UnoImage)" Resize="False" Condition="'%(UnoImage.Extension)' == '.gif' and '%(UnoImage.Resize)' == ''"/>
</ItemGroup>
<!-- Map @(UnoIcon) to @(UnoImage IsAppIcon=true) -->
<ItemGroup>
<UnoImage Include="@(UnoIcon)" IsAppIcon="True" Link="%(UnoIcon.Link)" />
</ItemGroup>
<!-- Write out item spec and metadata to a file we can use as an inputs for the resize target -->
<!-- This allows us to invalidate the build based on not just input image files changing but project item metadata as well -->
<WriteLinesToFile
File="$(_UnoResizetizerInputsFile)"
Lines="@(UnoImage->'File=%(Identity);Link=%(Link);BaseSize=%(BaseSize);Resize=%(Resize);TintColor=%(TintColor);Color=%(Color);IsAppIcon=%(IsAppIcon);ForegroundScale=%(ForegroundScale);ForegroundFile=%(ForegroundFile)')"
Overwrite="true"
WriteOnlyWhenDifferent="true"/>
<WriteLinesToFile
File="$(_UnoSplashInputsFile)"
Lines="@(UnoSplashScreen->'File=%(Identity);Link=%(Link);BaseSize=%(BaseSize);Resize=%(Resize);TintColor=%(TintColor);Color=%(Color);ForegroundScale=%(ForegroundScale)')"
Overwrite="true"
WriteOnlyWhenDifferent="true"/>
<ItemGroup>
<FileWrites Include="$(_UnoResizetizerInputsFile)"/>
<FileWrites Include="$(_UnoSplashInputsFile)"/>
</ItemGroup>
<ItemGroup>
<_SkiaManifest Include="@(EmbeddedResource)"
Condition="%(Extension) == '.appxmanifest'"/>
<EmbeddedResource Remove="@(EmbeddedResource)"
Condition="%(Extension) == '.appxmanifest'"/>
</ItemGroup>
</Target>
<Target Name="ProcessUnoAssets">
<PropertyGroup Condition="'$(_UnoResizetizerIsWindowsAppSdk)' == 'True'">
<_UnoAssetItemMetadata>TargetPath</_UnoAssetItemMetadata>
</PropertyGroup>
<ItemGroup Condition="'$(_UnoResizetizerIsWindowsAppSdk)' == 'True'">
<!-- Windows does not recognize %(LogicalName), so we must copy it to %(Link) -->
<UnoAsset Update="@(UnoAsset)" Link="%(UnoAsset.LogicalName)" Condition="'%(UnoAsset.Link)' == '' And '%(UnoAsset.LogicalName)' != ''"/>
</ItemGroup>
<GetUnoAssetPath_v0
ProjectDirectory="$(MSBuildProjectDirectory)"
ItemMetadata="$(_UnoAssetItemMetadata)"
Input="@(UnoAsset)">
<Output ItemName="AndroidAsset" TaskParameter="Output" Condition="'$(_UnoResizetizerIsAndroidApp)' == 'True'"/>
<Output ItemName="Content" TaskParameter="Output" Condition="'$(_UnoResizetizerIsiOSApp)' == 'True'"/>
<Output ItemName="ContentWithTargetPath" TaskParameter="Output" Condition="'$(_UnoResizetizerIsWindowsAppSdk)' == 'True'"/>
</GetUnoAssetPath_v0>
</Target>
<!-- This target is meant to be called by platform specific splash screen targets -->
<Target Name="GenerateUnoSplashScreens"
Condition="'@(UnoSplashScreen)' != ''">
<!--If not Windows-->
<ItemGroup Condition="$(_UnoResizetizerIsWasmApp) == 'True' Or $(_UnoResizetizerIsSkiaApp) == 'True' or '$(_UnoResizetizerIsAndroidApp)' == 'True' or ('$(_UnoResizetizerIsiOSApp)' == 'True' and '$(TargetPlatformIdentifier)' != 'maccatalyst')">
<UnoImage Include="@(UnoSplashScreen)" IsSplashScreen="True" Link=""/>
</ItemGroup>
<MakeDir Directories="$(IntermediateOutputPath)"/>
<!-- Stamp file for Outputs -->
<Touch Files="$(_UnoSplashStampFile)" AlwaysCreate="True"/>
<ItemGroup>
<FileWrites Include="$(_UnoSplashStampFile)"/>
</ItemGroup>
</Target>
<!-- UnoResizetizeImages must run at design time to avoid interactions with the `.R` generation on Android -->
<Target Name="UnoResizetizeImages"
Inputs="$(MSBuildThisFileFullPath);$(_UnoResizetizerTaskAssemblyName);$(_UnoResizetizerInputsFile);@(UnoImage);$(_UnoSplashInputsFile)"
Outputs="$(_UnoResizetizerStampFile)"
AfterTargets="$(UnoResizetizeAfterTargets)"
BeforeTargets="$(UnoResizetizeBeforeTargets)"
DependsOnTargets="$(UnoResizetizeDependsOnTargets)"
Condition="
'$(DesignTimeBuild)' != 'true'
OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' ">
<DetectInvalidResourceOutputFilenamesTask_v0
Items="@(UnoImage->Distinct())"
ErrorMessage="$(_UnoResizetizerDefaultInvalidFilenamesErrorMessage)">
</DetectInvalidResourceOutputFilenamesTask_v0>
<!-- Resize the images -->
<ResizetizeImages_v0
PlatformType="$(UnoResizetizerPlatformType)"
IntermediateOutputPath="$(_UnoIntermediateImages)"
IntermediateOutputIconPath="$(_UnoIntermediateAppIcon)"
PWAManifestPath="$(_WasmPwaManifestPath)"
InputsFile="$(_UnoResizetizerInputsFile);$(_UnoSplashInputsFile)"
TargetFramework="$(_UnoResizetizerPlatformIdentifier)"
Images="@(UnoImage->Distinct())">
<Output PropertyName="AppIconPath"
TaskParameter="GeneratedIconPath"/>
<Output PropertyName="AndroidIcons"
TaskParameter="AndroidAppIcons"/>
<Output PropertyName="UnoResizetizerPwaManifest"
TaskParameter="PwaGeneratedManifestPath"/>
</ResizetizeImages_v0>
<ItemGroup>
<!-- Get Images that were generated -->
<!-- Either from the task, or if the task was skipped (up to date), use the wildcard lookup -->
<_UnoResizetizerCollectedImages Condition="'@(CopiedResources)' != ''" Include="@(CopiedResources)"/>
<_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 AppIcon property is empty we can try to find it on the disk -->
<AppIconPath Condition="'$(AppIconPath)' == ''">%(_AppIconItemGroup.Identity)</AppIconPath>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon Condition="'$(ApplicationIcon)' == ''">$(AppIconPath)</ApplicationIcon>
</PropertyGroup>
<MakeDir Directories="$(IntermediateOutputPath)"/>
<!-- Touch/create our stamp file for outputs -->
<Touch Files="$(_UnoResizetizerStampFile)" AlwaysCreate="True"/>
<!-- Include our images and stamp file as filewrites so they don't get rm'd -->
<ItemGroup>
<FileWrites Include="$(_UnoResizetizerStampFile)"/>
</ItemGroup>
</Target>
<!-- ProcessResizedImages must run at design time to avoid interactions with the `.R` generation on Android -->
<Target Name="ProcessResizedImages"
AfterTargets="UnoResizetizeImages"
DependsOnTargets="UnoResizetizeImages"
Condition="
'$(DesignTimeBuild)' != 'true'
OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' ">
<ItemGroup Condition="'$(_UnoResizetizerIsWasmApp)' != 'True'">
<Content Include="@(_UnoResizetizerCollectedImages)"
Link="%(_UnoResizetizerCollectedImages.RecursiveDir)%(_UnoResizetizerCollectedImages.Filename)%(_UnoResizetizerCollectedImages.Extension)"
TargetPath="%(_UnoResizetizerCollectedImages.RecursiveDir)%(_UnoResizetizerCollectedImages.Filename)%(_UnoResizetizerCollectedImages.Extension)" />
<!--
Resizetizer output for WinAppSDK needs to be set to PreserveNewest
in order to be present in the final layout of an unpackaged app
-->
<Content Update="@(_UnoResizetizerCollectedImages)"
Condition="'$(_UnoResizetizerIsWindowsAppSdk)' == 'True'"
CopyToOutputDirectory="PreserveNewest"/>
<Content Update="@(Content)"
Condition="'%(Content.Extension)' == '.ico' And '$(_UnoResizetizerIsWindowsAppSdk)' == 'True'"
CopyToOutputDirectory="PreserveNewest"/>
<FileWrites Include="@(_UnoResizetizerCollectedImages)"/>
</ItemGroup>
<!--
Disables "XA0101 build action is not supported" as Uno handles Content items explicitly
https://github.com/xamarin/xamarin-android/blob/311b41e864a0162895d079477cb9398fbec5ca6e/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets#L833
-->
<ItemGroup Condition="'$(MonoAndroidAssetsPrefix)'!=''">
<Content Update="@(_UnoResizetizerCollectedImages)" ExcludeFromContentCheck="true"/>
</ItemGroup>
</Target>
<Target Name="_CleanUnoResizetizer">
<ItemGroup>
<_ResizetizerFilesToClean Include="$(_UnoResizetizerInputsFile)"/>
<_ResizetizerFilesToClean Include="$(_UnoResizetizerStampFile)"/>
<_ResizetizerFilesToClean Include="$(_UnoSplashInputsFile)"/>
<_ResizetizerFilesToClean Include="$(_UnoSplashStampFile)"/>
<_ResizetizerFilesToClean Include="$(_UnoManifestStampFile)"/>
</ItemGroup>
<RemoveDir Directories="$(_UnoResizetizerIntermediateOutputRoot)" Condition="Exists ('$(_UnoResizetizerIntermediateOutputRoot)' )"/>
<Delete Files="@(_ResizetizerFilesToClean)" />
<ItemGroup>
<_ResizetizerFilesToClean Remove="@(_ResizetizerFilesToClean)"/>
</ItemGroup>
</Target>
<Target Name="_GenerateWindowUnoIconExtension"
Condition="'$(_UnoResizetizerIsCompatibleApp)' == 'True'"
BeforeTargets="Build;CoreCompile;XamlPreCompile"
Inputs="@(UnoIcon)"
Outputs="@(_WindowIconExtension)">
<PropertyGroup>
<WindowTitle Condition="'$(WindowTitle)' == ''">$([MSBuild]::ValueOrDefault('$(ApplicationTitle)', '$(AssemblyName)'))</WindowTitle>
</PropertyGroup>
<WindowIconGeneratorTask_v0
IntermediateOutputDirectory="$(_UnoResizetizerIntermediateOutputRoot)"
WindowTitle="$(WindowTitle)"
UnoIcons="@(UnoIcon)">
<Output ItemName="GeneratedFile"
TaskParameter="GeneratedClass"/>
<Output ItemName="FilesWrite"
TaskParameter="GeneratedClass"/>
</WindowIconGeneratorTask_v0>
</Target>
<Target Name="_AddResizetizerWindowIconExtensions"
Condition="'$(_UnoResizetizerIsCompatibleApp)' == 'True' and '$(UnoResizetizerDisableWindowIconExtensions)'!='true'"
AfterTargets="_GenerateWindowUnoIconExtension"
BeforeTargets="Build;CoreCompile;XamlPreCompile">
<ItemGroup Condition="Exists('@(_WindowIconExtension->FullPath())')">
<Compile Include="@(_WindowIconExtension)"/>
</ItemGroup>
</Target>
<!--
This is used to get and copy the native runtime assets. This is a workaround as the assets aren't properly loading
Executed before UnoResizetizeImages for TargetFrameworks=='' and TargetFramework!=''
Executed before _SetBuildInnerTarget;_ComputeTargetFrameworkItems for TargetFrameworks!='' and TargetFramework==''
-->
<Target Name="_ResizetizerInitialize"
BeforeTargets="UnoResizetizeImages;_SetBuildInnerTarget;_ComputeTargetFrameworkItems">
<PropertyGroup>
<_ResizetizerRuntimeIdentifier>$(NETCoreSdkPortableRuntimeIdentifier)</_ResizetizerRuntimeIdentifier>
<!-- NOTE: We may need to adjust this in the future if we end up with assets compiled for osx-arm64 and osx-x64 -->
<_ResizetizerRuntimeIdentifier Condition=" $(_ResizetizerRuntimeIdentifier.Contains('osx')) ">osx</_ResizetizerRuntimeIdentifier>
<_ResizetizerRuntimeIdentifierDirectory>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'netstandard2.0', 'runtimes', '$(_ResizetizerRuntimeIdentifier)'))</_ResizetizerRuntimeIdentifierDirectory>
<_ResizetizerRuntimeAssetsOutput>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'netstandard2.0'))</_ResizetizerRuntimeAssetsOutput>
</PropertyGroup>
<ItemGroup>
<_ResiztizerRuntimeAssets Include="$(_ResizetizerRuntimeIdentifierDirectory)\**\*"
OutputDirectory="$(_ResizetizerRuntimeAssetsOutput)" />
</ItemGroup>
<Error Text="No Runtime was found."
Condition="$(_ResizetizerRuntimeIdentifier) == ''" />
<Error Text="The selected runtime directory does not exist"
Condition="!Exists('$(_ResizetizerRuntimeIdentifierDirectory)')" />
<!--
Try to copy files with one retry, fail fast and ignore the error if this happens, then retry
copying the files in a second time. This is present to avoid a race condition during
cross-targeted builds when this current target is executed concurrently.
When running, the Copy task may detect that files are not present for two
threads/processes, then assume it's safe to copy, while only one of them can do
so. Later on, the copied files may be locked by dotnet/msbuild and the other copy
instance never finishes sucessfully, regardless of SkipUnchangedFiles.
-->
<Copy SourceFiles="@(_ResiztizerRuntimeAssets)"
DestinationFiles="@(_ResiztizerRuntimeAssets->'%(OutputDirectory)\%(Filename)%(Extension)')"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="true"
Condition="Exists('$(_ResizetizerRuntimeIdentifierDirectory)')"
UseHardlinksIfPossible="true"
ContinueOnError="true"
Retries="1"
UseSymboliclinksIfPossible="true" />
<Copy SourceFiles="@(_ResiztizerRuntimeAssets)"
DestinationFiles="@(_ResiztizerRuntimeAssets->'%(OutputDirectory)\%(Filename)%(Extension)')"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="true"
Condition="Exists('$(_ResizetizerRuntimeIdentifierDirectory)')"
UseHardlinksIfPossible="true"
UseSymboliclinksIfPossible="true" />
</Target>
</Project>