Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set AppWindow.Title to DisplayName #211

Merged
merged 11 commits into from
Jan 31, 2024
6 changes: 6 additions & 0 deletions src/.nuspec/Uno.Resizetizer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,14 @@
BeforeTargets="Build;CoreCompile;XamlPreCompile"
Inputs="@(UnoIcon)"
Outputs="@(_WindowIconExtension)">

<PropertyGroup>
<WindowTitle Condition="'$(WindowTitle)' == ''">$(ApplicationTitle)</WindowTitle>
</PropertyGroup>

<WindowIconGeneratorTask_v0
IntermediateOutputDirectory="$(_UnoResizetizerIntermediateOutputRoot)"
WindowTitle="$(WindowTitle)"
UnoIcons="@(UnoIcon)">
<Output ItemName="GeneratedFile"
TaskParameter="GeneratedClass"/>
Expand Down
12 changes: 8 additions & 4 deletions src/.nuspec/Uno.Resizetizer.windows.skia.targets
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project>

<Target
<Target
Name="UpdatePathOfUnoIcon"
BeforeTargets="UnoResizetizeCollectItems"
DependsOnTargets="ValidateAvailableItems">

<AssignLinkMetadata Items="@(UnoIcon)">
<Output TaskParameter="OutputItems" ItemName="_UnoIconLinked"/>
</AssignLinkMetadata>
Expand Down Expand Up @@ -52,10 +52,11 @@
BeforeTargets="_ValidatePresenceOfAppxManifestItems"
DependsOnTargets="UnoGeneratePackageAppxManifest"
Condition="'$(_UnoResizetizerIsWindowsAppSdk)' == 'True' Or '$(_UnoResizetizerIsSkiaApp)' == 'True'"/>

<Target Name="UnoGeneratePackageAppxManifest"
Condition="('$(_UnoResizetizerIsWindowsAppSdk)' == 'True' Or '$(_UnoResizetizerIsSkiaApp)' == 'True') And ('@(AppxManifest)@(_UnoAppxManifest)' !='' Or @(_SkiaManifest) != '')"
DependsOnTargets="$(UnoGeneratePackageAppxManifestDependsOnTargets)"
BeforeTargets="$(UnoGeneratePackageAppxManifestBeforeTargets)"
BeforeTargets="$(UnoGeneratePackageAppxManifestBeforeTargets);_GenerateWindowUnoIconExtension"
Inputs="$(MSBuildThisFileFullPath);$(_UnoResizetizerTaskAssemblyName);$(_UnoResizetizerInputsFile);$(_UnoSplashInputsFile);@(AppxManifest);@(_UnoAppxManifest)"
Outputs="$(_UnoManifestStampFile);$(_UnoIntermediateManifest)Package.appxmanifest">

Expand All @@ -81,7 +82,10 @@
ApplicationTitle="$(ApplicationTitle)"
AppIcon="@(UnoImage->WithMetadataValue('IsAppIcon', 'true'))"
TargetFramework="$(_UnoResizetizerPlatformIdentifier)"
SplashScreen="@(UnoSplashScreen)"/>
SplashScreen="@(UnoSplashScreen)">
<Output PropertyName="WindowTitle"
TaskParameter="DisplayName"/>
</GeneratePackageAppxManifest_v0>

<!-- replace user manifest -->
<ItemGroup Condition="'@(AppxManifest)' != ''">
Expand Down
13 changes: 9 additions & 4 deletions src/Resizetizer/src/GeneratePackageAppxManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ public class GeneratePackageAppxManifest_v0 : Task
[Output]
public ITaskItem GeneratedAppxManifest { get; set; } = null!;

[Output]
public string DisplayName { get; private set; } = null!;
pictos marked this conversation as resolved.
Show resolved Hide resolved

public override bool Execute()
{
#if DEBUG_RESIZETIZER
// System.Diagnostics.Debugger.Launch();
//System.Diagnostics.Debugger.Launch();
#endif
try
{
Expand Down Expand Up @@ -144,16 +147,18 @@ void UpdateManifest(XDocument appx)
}

// <DisplayName>
var xdisplayname = xmlns + "DisplayName";
if (!string.IsNullOrEmpty(ApplicationTitle))
{
var xname = xmlns + "DisplayName";
var xelem = properties.Element(xname);
var xelem = properties.Element(xdisplayname);
if (xelem == null || string.IsNullOrEmpty(xelem.Value) || xelem.Value == DefaultPlaceholder)
{
properties.SetElementValue(xname, ApplicationTitle);
properties.SetElementValue(xdisplayname, ApplicationTitle);
}
}

DisplayName = properties.Element(xdisplayname).Value;

// <Logo>
if (appIconInfo != null)
{
Expand Down
6 changes: 4 additions & 2 deletions src/Resizetizer/src/WindowIconGeneratorTask.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
Expand All @@ -15,6 +14,8 @@ public class WindowIconGeneratorTask_V0 : Task
[Required]
public string IntermediateOutputDirectory { get; set; }

public string WindowTitle { get; set; }

[Output]
public ITaskItem[] GeneratedClass { get; private set; } = Array.Empty<ITaskItem>();

Expand Down Expand Up @@ -68,6 +69,7 @@ public static void SetWindowIcon(this global::Microsoft.UI.Xaml.Window window)
global::Microsoft.UI.Windowing.AppWindow appWindow =
global::Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
appWindow.SetIcon(""{iconName}.ico"");
appWindow.Title = ""{WindowTitle}"";
#endif
}}
}}
Expand All @@ -82,5 +84,5 @@ public static void SetWindowIcon(this global::Microsoft.UI.Xaml.Window window)
File.WriteAllText(item.ItemSpec, code);
GeneratedClass = new [] { item };
return true;
}
}
}
Loading