diff --git a/src/Resizetizer/src/GeneratePackageAppxManifest.cs b/src/Resizetizer/src/GeneratePackageAppxManifest.cs index d0a44571..7437eeec 100644 --- a/src/Resizetizer/src/GeneratePackageAppxManifest.cs +++ b/src/Resizetizer/src/GeneratePackageAppxManifest.cs @@ -24,7 +24,7 @@ public class GeneratePackageAppxManifest_v0 : Task public string IntermediateOutputPath { get; set; } = null!; [Required] - public ITaskItem AppxManifest { get; set; } = null!; + public ITaskItem[] AppxManifest { get; set; } = Array.Empty(); public string? TargetFramework { get; set; } @@ -60,7 +60,12 @@ public override bool Execute() var filename = Path.Combine(IntermediateOutputPath, GeneratedFilename ?? "Package.appxmanifest"); - var appx = XDocument.Load(AppxManifest.ItemSpec); + if (AppxManifest.Length > 1) + { + Log.LogWarning("Multiple AppxManifest files were provided. Only the first one will be used."); + } + + var appx = XDocument.Load(AppxManifest[0].ItemSpec); UpdateManifest(appx); diff --git a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs index 58966c12..83b74a2e 100644 --- a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs +++ b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs @@ -1,7 +1,8 @@ #nullable enable using Microsoft.Build.Framework; using Microsoft.Build.Utilities; -using System.Collections.Generic; +using System; +using System.Collections; using System.IO; using System.Linq; using System.Xml.Linq; @@ -26,12 +27,36 @@ protected GeneratePackageAppxManifest_v0 GetNewTask( IntermediateOutputPath = DestinationDirectory, BuildEngine = this, GeneratedFilename = generatedFilename, - AppxManifest = new TaskItem(manifest), + AppxManifest = new []{new TaskItem(manifest)}, ApplicationId = guid, ApplicationDisplayVersion = displayVersion, ApplicationVersion = version, - ApplicationTitle = displayName, - AppIcon = appIcon == null ? null : new[] { appIcon }, + ApplicationTitle = displayName,AppIcon = appIcon == null ? null : new[] { appIcon }, + SplashScreen = splashScreen == null ? null : new[] { splashScreen }, + TargetFramework = "windows" + }; + } + + protected GeneratePackageAppxManifest_v0 GetNewTask( + ITaskItem[] appxManifests, + string? generatedFilename = null, + string? guid = null, + string? displayVersion = null, + string? version = null, + string? displayName = null, + ITaskItem? appIcon = null, + ITaskItem? splashScreen = null) + { + return new() + { + IntermediateOutputPath = DestinationDirectory, + BuildEngine = this, + GeneratedFilename = generatedFilename, + AppxManifest = appxManifests, + ApplicationId = guid, + ApplicationDisplayVersion = displayVersion, + ApplicationVersion = version, + ApplicationTitle = displayName,AppIcon = appIcon == null ? null : new[] { appIcon }, SplashScreen = splashScreen == null ? null : new[] { splashScreen }, TargetFramework = "windows" }; @@ -45,6 +70,7 @@ public void FileIsGenerated(string? specificFn, string outputFn) var task = GetNewTask($"testdata/appxmanifest/typical.appxmanifest", generatedFilename: specificFn); var success = task.Execute(); + Assert.True(success, $"{task.GetType()}.Execute() failed: " + LogErrorEvents.FirstOrDefault()?.Message); Assert.True(File.Exists(Path.Combine(DestinationDirectory, outputFn)), "Package.appxmanifest file was not generated."); @@ -183,5 +209,19 @@ public void InvalidMergeVersionNumbers(string displayVersion, string appVersion) var result = GeneratePackageAppxManifest_v0.TryMergeVersionNumbers(displayVersion, appVersion, out var merged); Assert.False(result); } + + [Fact] + public void TaskShouldFileAWarningIfMoreThanOneManifestIsProvided() + { + // Arrange + var taskItem = new TaskItem("testdata/appxmanifest/typical.appxmanifest"); + var task = GetNewTask(appxManifests: new [] {taskItem, taskItem}); + + // Act + task.Execute(); + + // Assert + Assert.True(LogWarningEvents.Count > 0, "Warnings should be greater than zero"); + } } } diff --git a/src/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj b/src/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj index 44545ef8..17fee812 100644 --- a/src/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj +++ b/src/Resizetizer/test/UnitTests/Resizetizer.UnitTests.csproj @@ -1,36 +1,37 @@  - - net7.0 - Uno.Resizetizer.UnitTests - false - $(DefineConstants);WINDOWS - Debug;Release;DEBUG_RESIZETIZER - + + net7.0 + Uno.Resizetizer.UnitTests + false + $(DefineConstants);WINDOWS + Debug;Release;DEBUG_RESIZETIZER + latest + - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - - + + + - - - - - + + + + +