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

Swap the POC for TRA in PowerToys #246

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pipelines/ESRPSigning_core.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"WinUI3Apps\\PowerToys.Settings.exe",

"PowerToys.CmdPalModuleInterface.dll",
"*Microsoft.CmdPal.UI.Poc_*.msix"
"*Microsoft.CmdPal.UI_*.msix"
],
"SigningInfo": {
"Operations": [
Expand Down
4 changes: 2 additions & 2 deletions .pipelines/v2/templates/job-build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ jobs:

- ${{ if eq(parameters.codeSign, true) }}:
- pwsh: |-
$Package = (Get-ChildItem -Recurse -Filter "Microsoft.CmdPal.UI.Poc*.msix" | Select -First 1)
$Package = (Get-ChildItem -Recurse -Filter "Microsoft.CmdPal.UI_*.msix" | Select -First 1)
$PackageFilename = $Package.FullName
Write-Host "##vso[task.setvariable variable=CmdPalPackagePath]${PackageFilename}"
displayName: Locate the MSIX
Expand All @@ -403,7 +403,7 @@ jobs:
displayName: Sign CmdPal MSIX content
signingIdentity: ${{ parameters.signingIdentity }}
inputs:
FolderPath: '$(JobOutputDirectory)/CmdPalPackageContents' # Video conf uses x86 and x64.
FolderPath: '$(JobOutputDirectory)/CmdPalPackageContents'
signType: batchSigning
batchSignPolicyFile: '$(build.sourcesdirectory)\.pipelines\ESRPSigning_cmdpal_msix_content.json'
ciPolicyFile: '$(build.sourcesdirectory)\.pipelines\CIPolicy.xml'
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/v2/templates/steps-build-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ steps:
$searchDir = "extractedMsi\File"

# Define the regex pattern for MSIX files
$pattern = '^Microsoft.CmdPal.UI.Poc.*\.msix$'
$pattern = '^Microsoft.CmdPal.UI.*\.msix$'

# Get all files in the directory and subdirectories
$msixFile = Get-ChildItem -Path $searchDir -Recurse -File | Where-Object {
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/versionSetting.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Write-Host "NewPlusContextMenu version" $newPlusContextMenuAppManifest.Package.I
$newPlusContextMenuAppManifest.Save($newPlusContextMenuAppManifestWriteFileLocation);

# Set package version in Package.appxmanifest
$cmdPalAppManifestWriteFileLocation = $PSScriptRoot + '/../src/modules/cmdpal/WindowsCommandPalette/Package.appxmanifest';
$cmdPalAppManifestWriteFileLocation = $PSScriptRoot + '/../src/modules/cmdpal/Microsoft.CmdPal.UI/Package.appxmanifest';
$cmdPalAppManifestReadFileLocation = $cmdPalAppManifestWriteFileLocation;

[XML]$cmdPalAppManifest = Get-Content $cmdPalAppManifestReadFileLocation
Expand Down
18 changes: 9 additions & 9 deletions installer/PowerToysSetup/CmdPal.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,38 @@
</Directory>
</DirectoryRef>

<DirectoryRef Id="CmdPalInstallFolder" FileSource="$(var.BinDir)\WinUI3Apps\CmdPal.POC\AppPackages\Microsoft.CmdPal.UI.Poc_$(var.Version).0_Test">
<DirectoryRef Id="CmdPalInstallFolder" FileSource="$(var.BinDir)\WinUI3Apps\CmdPal\AppPackages\Microsoft.CmdPal.UI_$(var.Version).0_Test">
<Component Id="Module_CmdPal" Win64="yes" Guid="3A4942B2-1A86-4182-B3B4-65157365A980">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="Module_CmdPal" Value="" KeyPath="yes"/>
</RegistryKey>
<?if $(sys.BUILDARCH) = x64 ?>
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal.POC\AppPackages\Microsoft.CmdPal.UI.Poc_$(var.Version).0_Test\Microsoft.CmdPal.UI.Poc_$(var.Version).0_x64.msix" />
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal\AppPackages\Microsoft.CmdPal.UI_$(var.Version).0_Test\Microsoft.CmdPal.UI_$(var.Version).0_x64.msix" />
<?else ?>
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal.POC\AppPackages\Microsoft.CmdPal.UI.Poc_$(var.Version).0_Test\Microsoft.CmdPal.UI.Poc_$(var.Version).0_arm64.msix" />
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal\AppPackages\Microsoft.CmdPal.UI_$(var.Version).0_Test\Microsoft.CmdPal.UI_$(var.Version).0_arm64.msix" />
<?endif ?>

</Component>
</DirectoryRef>

<?if $(sys.BUILDARCH) = x64 ?>
<DirectoryRef Id="CmdPalDepsx64InstallFolder" FileSource="$(var.BinDir)\WinUI3Apps\CmdPal.POC\AppPackages\Microsoft.CmdPal.UI.Poc_$(var.Version).0_Test\Dependencies\x64">
<DirectoryRef Id="CmdPalDepsx64InstallFolder" FileSource="$(var.BinDir)\WinUI3Apps\CmdPal\AppPackages\Microsoft.CmdPal.UI_$(var.Version).0_Test\Dependencies\x64">

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[Depsx](#security-tab) is not a recognized word. \(unrecognized-spelling\)
<Component Id="Module_CmdPal_Deps" Win64="yes" Guid="C2790FC4-0665-4462-947A-D942A2AABFF0">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="Module_CmdPal_Deps" Value="" KeyPath="yes"/>
</RegistryKey>
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal.POC\AppPackages\Microsoft.CmdPal.UI.Poc_$(var.Version).0_Test\Dependencies\x64\Microsoft.VCLibs.x64.14.00.Desktop.appx" />
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal.POC\AppPackages\Microsoft.CmdPal.UI.Poc_$(var.Version).0_Test\Dependencies\x64\Microsoft.WindowsAppRuntime.1.6.msix" />
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal\AppPackages\Microsoft.CmdPal.UI_$(var.Version).0_Test\Dependencies\x64\Microsoft.VCLibs.x64.14.00.Desktop.appx" />
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal\AppPackages\Microsoft.CmdPal.UI_$(var.Version).0_Test\Dependencies\x64\Microsoft.WindowsAppRuntime.1.6.msix" />
</Component>
</DirectoryRef>
<?else ?>
<DirectoryRef Id="CmdPalDepsArm64InstallFolder" FileSource="$(var.BinDir)\WinUI3Apps\CmdPal.POC\AppPackages\Microsoft.CmdPal.UI.Poc_$(var.Version).0_Test\Dependencies\arm64">
<DirectoryRef Id="CmdPalDepsArm64InstallFolder" FileSource="$(var.BinDir)\WinUI3Apps\CmdPal\AppPackages\Microsoft.CmdPal.UI_$(var.Version).0_Test\Dependencies\arm64">
<Component Id="Module_CmdPal_Deps" Win64="yes" Guid="C2790FC4-0665-4462-947A-D942A2AABFF0">
<RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
<RegistryValue Type="string" Name="Module_CmdPal_Deps" Value="" KeyPath="yes"/>
</RegistryKey>
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal.POC\AppPackages\Microsoft.CmdPal.UI.Poc_$(var.Version).0_Test\Dependencies\arm64\Microsoft.VCLibs.ARM64.14.00.Desktop.appx" />
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal.POC\AppPackages\Microsoft.CmdPal.UI.Poc_$(var.Version).0_Test\Dependencies\arm64\Microsoft.WindowsAppRuntime.1.6.msix" />
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal\AppPackages\Microsoft.CmdPal.UI_$(var.Version).0_Test\Dependencies\arm64\Microsoft.VCLibs.ARM64.14.00.Desktop.appx" />
<File Source="$(var.BinDir)\WinUI3Apps\CmdPal\AppPackages\Microsoft.CmdPal.UI_$(var.Version).0_Test\Dependencies\arm64\Microsoft.WindowsAppRuntime.1.6.msix" />
</Component>
</DirectoryRef>
<?endif ?>
Expand Down
12 changes: 8 additions & 4 deletions src/modules/cmdpal/Exts/Microsoft.CmdPal.Ext.Apps/AllAppsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,18 @@ internal static List<AppItem> GetPrograms()
var win32Results = win32s
.Where((application) => application.Enabled /*&& application.Valid*/)
.Select(app =>
new AppItem
{
return new AppItem
{
Name = app.Name,
Subtitle = app.Description,
IcoPath = app.FullPath, // similarly, this should be IcoPath, but :shrug:
ExePath = app.LnkFilePath ?? app.FullPath,
IcoPath = app.AppType == Win32Program.ApplicationType.InternetShortcutApplication ?
app.IcoPath :
app.FullPath,
ExePath = !string.IsNullOrEmpty(app.LnkFilePath) ? app.LnkFilePath : app.FullPath,
DirPath = app.Location,
});
};
});

return uwpResults.Concat(win32Results).OrderBy(app => app.Name).ToList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.IO;
using System.Linq;
using System.Security;
using System.Text.RegularExpressions;
using Microsoft.Win32;

namespace Microsoft.CmdPal.Ext.Apps.Programs;
Expand Down Expand Up @@ -222,10 +223,82 @@ private static Win32Program CreateWin32Program(string path)
}
}

private static readonly Regex InternetShortcutURLPrefixes = new(@"^steam:\/\/(rungameid|run|open)\/|^com\.epicgames\.launcher:\/\/apps\/", RegexOptions.Compiled);

// This function filters Internet Shortcut programs
private static Win32Program InternetShortcutProgram(string path)
{
return InvalidProgram;
try
{
// We don't want to read the whole file if we don't need to
var lines = File.ReadLines(path);
var iconPath = string.Empty;
var urlPath = string.Empty;
var validApp = false;

const string urlPrefix = "URL=";
const string iconFilePrefix = "IconFile=";

foreach (var line in lines)
{
// Using OrdinalIgnoreCase since this is used internally
if (line.StartsWith(urlPrefix, StringComparison.OrdinalIgnoreCase))
{
urlPath = line.Substring(urlPrefix.Length);

if (!Uri.TryCreate(urlPath, UriKind.RelativeOrAbsolute, out var _))
{
// ProgramLogger.Warn("url could not be parsed", null, MethodBase.GetCurrentMethod().DeclaringType, urlPath);
return InvalidProgram;
}

// To filter out only those steam shortcuts which have 'run' or 'rungameid' as the hostname
if (InternetShortcutURLPrefixes.Match(urlPath).Success)
{
validApp = true;
}
}
else if (line.StartsWith(iconFilePrefix, StringComparison.OrdinalIgnoreCase))
{
iconPath = line.Substring(iconFilePrefix.Length);
}

// If we resolved an urlPath & and an iconPath quit reading the file
if (!string.IsNullOrEmpty(urlPath) && !string.IsNullOrEmpty(iconPath))
{
break;
}
}

if (!validApp)
{
return InvalidProgram;
}

try
{
return new Win32Program
{
Name = Path.GetFileNameWithoutExtension(path),
ExecutableName = Path.GetFileName(path),
IcoPath = iconPath,
FullPath = urlPath,
UniqueIdentifier = path,
ParentDirectory = Directory.GetParent(path)?.FullName ?? string.Empty,
Valid = true,
Enabled = true,
AppType = ApplicationType.InternetShortcutApplication,
};
}
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
{
return InvalidProgram;
}
}
catch (Exception)
{
return InvalidProgram;
}
}

private static Win32Program LnkProgram(string path)
Expand Down Expand Up @@ -422,7 +495,7 @@ private static IEnumerable<string> ProgramPaths(string directory, IList<string>
{
files.AddRange(Directory.EnumerateFiles(currentDirectory, $"*.{suffix}", SearchOption.TopDirectoryOnly));
}
catch (DirectoryNotFoundException )
catch (DirectoryNotFoundException)
{
// ProgramLogger.Warn("|The directory trying to load the program from does not exist", e, MethodBase.GetCurrentMethod().DeclaringType, currentDirectory);
}
Expand All @@ -432,7 +505,7 @@ private static IEnumerable<string> ProgramPaths(string directory, IList<string>
{
// ProgramLogger.Warn($"|Permission denied when trying to load programs from {currentDirectory}", e, MethodBase.GetCurrentMethod().DeclaringType, currentDirectory);
}
catch (Exception )
catch (Exception)
{
// ProgramLogger.Exception($"|An unexpected error occurred in the calling method ProgramPaths at {currentDirectory}", e, MethodBase.GetCurrentMethod().DeclaringType, currentDirectory);
}
Expand Down Expand Up @@ -460,7 +533,7 @@ private static IEnumerable<string> ProgramPaths(string directory, IList<string>
{
// ProgramLogger.Warn($"|Permission denied when trying to load programs from {currentDirectory}", e, MethodBase.GetCurrentMethod().DeclaringType, currentDirectory);
}
catch (Exception )
catch (Exception)
{
// ProgramLogger.Exception($"|An unexpected error occurred in the calling method ProgramPaths at {currentDirectory}", e, MethodBase.GetCurrentMethod().DeclaringType, currentDirectory);
}
Expand Down Expand Up @@ -617,12 +690,9 @@ private sealed class Win32ProgramEqualityComparer : IEqualityComparer<Win32Progr

public bool Equals(Win32Program? app1, Win32Program? app2)
{
if (app1 == null && app2 == null)
{
return true;
}

return app1 != null
return app1 == null && app2 == null
? true
: app1 != null
&& app2 != null
&& (app1.Name?.ToUpperInvariant(), app1.ExecutableName?.ToUpperInvariant(), app1.FullPath?.ToUpperInvariant())
.Equals((app2.Name?.ToUpperInvariant(), app2.ExecutableName?.ToUpperInvariant(), app2.FullPath?.ToUpperInvariant()));
Expand Down Expand Up @@ -682,7 +752,7 @@ private static bool TryGetIcoPathForRunCommandProgram(Win32Program program, out
icoPath = ExpandEnvironmentVariables(redirectionPath);
return true;
}
catch (IOException )
catch (IOException)
{
// ProgramLogger.Warn($"|Error whilst retrieving the redirection path from app execution alias {program.FullPath}", e, MethodBase.GetCurrentMethod().DeclaringType, program.FullPath);
}
Expand Down Expand Up @@ -746,7 +816,7 @@ public static IList<Win32Program> All()

return DeduplicatePrograms(programs.Concat(runCommandPrograms).Where(program => program?.Valid == true));
}
catch (Exception )
catch (Exception)
{
// ProgramLogger.Exception("An unexpected error occurred", e, MethodBase.GetCurrentMethod().DeclaringType, "Not available");
return Array.Empty<Win32Program>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
</PropertyGroup>


<PropertyGroup>
<!-- This lets us actually reference types from Microsoft.Terminal.UI -->
<CsWinRTIncludes>Microsoft.Terminal.UI</CsWinRTIncludes>
Expand Down Expand Up @@ -52,7 +51,7 @@
<ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" />
<PackageReference Include="CommunityToolkit.WinUI.Converters" />
<PackageReference Include="CommunityToolkit.WinUI.Animations" />
<PackageReference Include="CommunityToolkit.WinUI.Animations" />
<PackageReference Include="CommunityToolkit.WinUI.Extensions" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Markdown" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
Expand Down
4 changes: 1 addition & 3 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
<ColumnDefinition x:Name="DetailsColumn" Width="Auto" />
</Grid.ColumnDefinitions>

<Frame
Name="RootFrame"
IsNavigationStackEnabled="True" />
<Frame Name="RootFrame" IsNavigationStackEnabled="True" />

<Grid
x:Name="DetailsContent"
Expand Down
2 changes: 1 addition & 1 deletion src/settings-ui/Settings.UI/ViewModels/CmdPalViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class CmdPalViewModel : Observable
{
private static readonly string PackageName = "Microsoft.CmdPal.POC";
private static readonly string PackageName = "Microsoft.CmdPal";

private GpoRuleConfigured _enabledGpoRuleConfiguration;
private bool _isEnabled;
Expand Down
Loading