Skip to content

Commit

Permalink
v0.8.1 hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
rayenghanmi committed Apr 15, 2024
1 parent 3090141 commit 066ac20
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 78 deletions.
4 changes: 1 addition & 3 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args)
{
base.OnLaunched(args);

var showWelcomeNotification = ShouldShowWelcomeNotification();

if (showWelcomeNotification)
if (ShouldShowWelcomeNotification())
{
await LogHelper.Log("Showing Welcome Notification");
App.MainWindow.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this branch will be documented in this file.

## 0.8.1 - Released

> This is a hotfix for version 0.8.0
## Added

- Add Simplified Chinese translation

## Fixes

- [x] Resolved an issue stopping users on Windows 10 from using `Debloat`.

## Known Issues

- This hotfix broke the ability to remove `MicrosoftEdge` (will be fixed in the next version).

## 0.8.0 - Released

### Fixes
Expand Down
79 changes: 45 additions & 34 deletions Helpers/OptimizationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System.Collections.ObjectModel;
using System.Management.Automation;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml;
using System.Reflection;

namespace RyTuneX.Helpers;
internal class OptimizationOptions
Expand All @@ -13,51 +11,64 @@ public static List<KeyValuePair<string, string>> GetUWPApps(bool uninstallableOn
{
var installedApps = new List<KeyValuePair<string, string>>();

using (var PowerShellInstance = PowerShell.Create())
string command;
if (uninstallableOnly)
{
LogHelper.Log("Getting Installed Apps [OptimizationOptions.cs]");
PowerShellInstance.AddScript("Set-ExecutionPolicy RemoteSigned -Scope Process");
PowerShellInstance.AddScript("Import-Module Appx")
.AddArgument("-ExecutionPolicy Bypass");
command = @"powershell.exe -Command ""Get-AppxPackage | Where-Object { $_.NonRemovable -eq $false } | Select-Object Name,InstallLocation""";
}
else
{
command = @"powershell.exe -Command ""Get-AppxPackage | Select-Object Name,InstallLocation""";
}

if (uninstallableOnly)
try
{
using var process = new Process
{
PowerShellInstance.AddScript(@"Get-AppxPackage | Where {$_.NonRemovable -like ""False""} | Select Name,InstallLocation");
}
else
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/C {command}",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
}
};
{
PowerShellInstance.AddScript("Get-AppxPackage | Select Name,InstallLocation");
}
process.Start();

string[] tmp;
Collection<PSObject> psResult;
try
{
psResult = PowerShellInstance.Invoke();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
return installedApps;
}
/* Skip the first two lines as they contain headers
Removing this will cause two apps to appear named
"----" and "Name" */
process.StandardOutput.ReadLine();
process.StandardOutput.ReadLine();
process.StandardOutput.ReadLine();

if (psResult == null)
{
return installedApps;
}
foreach (var x in psResult)
{
tmp = x.ToString().Replace("@", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("Name=", string.Empty).Replace("InstallLocation=", string.Empty).Trim().Split(';');
if (!installedApps.Exists(i => i.Key == tmp[0]))
// Read the output directly
while (!process.StandardOutput.EndOfStream)
{
installedApps.Add(new KeyValuePair<string, string>(tmp[0], tmp[1]));
var line = process.StandardOutput.ReadLine();
var parts = line?.Split(new[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
if (parts?.Length == 2 && !installedApps.Exists(i => i.Key == parts[0]))
{
installedApps.Add(new KeyValuePair<string, string>(parts[0], parts[1]));
}
}

process.WaitForExit();
}
}
LogHelper.Log("Returning Installed Apps [OptimizationOptions.cs]");
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
return installedApps;
}

LogHelper.Log("Returning Installed Apps [GetUWPApps]");
return installedApps;
}


internal static bool ServiceExists(string serviceName)
{
return Array.Exists(ServiceController.GetServices(), (serviceController => serviceController.ServiceName.Equals(serviceName)));
Expand Down
2 changes: 1 addition & 1 deletion Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Identity
Name="Rayen.RyTuneX"
Publisher="CN=Rayen Ghanmi"
Version="0.8.0.0" />
Version="0.8.1.0" />

<mp:PhoneIdentity PhoneProductId="593c7ba8-f1c9-47cf-a952-7c22b10aac3a" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
30 changes: 15 additions & 15 deletions RyTuneX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.0.230907" />
<PackageReference Include="CommunityToolkit.WinUI.Behaviors" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240404000" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="System.Management" Version="8.0.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
<PackageReference Include="WinUI3Localizer" Version="2.1.0" />
<PackageReference Include="WinUIEx" Version="2.3.3" />
<PackageReference Include="Microsoft.PowerShell.Commands.Diagnostics" Version="7.4.0" />
<PackageReference Include="Microsoft.PowerShell.Commands.Management" Version="7.4.0" />
<PackageReference Include="Microsoft.PowerShell.Commands.Utility" Version="7.4.0" />
<PackageReference Include="Microsoft.PowerShell.ConsoleHost" Version="7.4.0" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.4.0" />
<PackageReference Include="WinUI3Localizer" Version="2.2.0" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="Microsoft.PowerShell.Commands.Diagnostics" Version="7.4.2" />
<PackageReference Include="Microsoft.PowerShell.Commands.Management" Version="7.4.2" />
<PackageReference Include="Microsoft.PowerShell.Commands.Utility" Version="7.4.2" />
<PackageReference Include="Microsoft.PowerShell.ConsoleHost" Version="7.4.2" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.4.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
<PackageReference Include="System.Management.Automation" Version="7.4.0" />
<PackageReference Include="System.Management.Automation" Version="7.4.2" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -99,26 +99,26 @@
</PropertyGroup>

<ItemGroup>
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.4.231115000\buildTransitive\..\include\DeploymentManagerAutoInitializer.cs" />
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.5.240404000\buildTransitive\..\include\DeploymentManagerAutoInitializer.cs" />
</ItemGroup>

<ItemGroup>
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.4.231115000\buildTransitive\..\include\WindowsAppSDK-VersionInfo.cs" />
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.5.240404000\buildTransitive\..\include\WindowsAppSDK-VersionInfo.cs" />
</ItemGroup>

<ItemGroup>
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.4.231115000\buildTransitive\..\include\WindowsAppSDK-VersionInfo.cs" />
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.5.240404000\buildTransitive\..\include\WindowsAppSDK-VersionInfo.cs" />
</ItemGroup>

<ItemGroup>
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.4.231115000\buildTransitive\..\include\WindowsAppSDK-VersionInfo.cs" />
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.5.240404000\buildTransitive\..\include\WindowsAppSDK-VersionInfo.cs" />
</ItemGroup>

<ItemGroup>
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.4.231115000\buildTransitive\..\include\WindowsAppSDK-VersionInfo.cs" />
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.5.240404000\buildTransitive\..\include\WindowsAppSDK-VersionInfo.cs" />
</ItemGroup>

<ItemGroup>
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.4.231115000\buildTransitive\..\include\DeploymentManagerAutoInitializer.cs" />
<Compile Remove="C:\Users\Ghanmi\.nuget\packages\microsoft.windowsappsdk\1.5.240404000\buildTransitive\..\include\DeploymentManagerAutoInitializer.cs" />
</ItemGroup>
</Project>
14 changes: 1 addition & 13 deletions Views/DebloatSystemPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
mc:Ignorable="d">
<Grid Margin="0,0,0,26">
<Grid.ChildrenTransitions>
<EntranceThemeTransition FromVerticalOffset="50" />
<RepositionThemeTransition IsStaggeringEnabled="True" />
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
Expand All @@ -27,7 +23,7 @@
<TreeView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Key}" Loaded="TextBlock_Loaded" />
<TextBlock Text="{Binding Key}" />
<TextBlock Text="{Binding Value}" Visibility="Collapsed"/>
</StackPanel>
</DataTemplate>
Expand Down Expand Up @@ -55,17 +51,9 @@
</interactivity:Interaction.Behaviors>
</muxc:InfoBar>
<StackPanel Orientation="Horizontal" Margin="3" Grid.Row="5">
<StackPanel.ChildrenTransitions>
<EntranceThemeTransition FromVerticalOffset="50" />
<RepositionThemeTransition IsStaggeringEnabled="True" />
</StackPanel.ChildrenTransitions>
<Button Margin="3" x:Uid="DebloatSystemPage_UninstallButton" x:Name="uninstallButton" Visibility="Collapsed" Click="UninstallSelectedApp_Click"/>
<StackPanel x:Name="TempStackButtonTextBar" Margin="3" Orientation="Vertical" VerticalAlignment="Center" Visibility="Collapsed">
<Grid>
<Grid.ChildrenTransitions>
<EntranceThemeTransition FromVerticalOffset="50" />
<RepositionThemeTransition IsStaggeringEnabled="True" />
</Grid.ChildrenTransitions>
<Button x:Uid="DebloatSystemPage_TempButton" x:Name="TempButton" Click="RemoveTempFiles"/>
<StackPanel x:Name="TempStack" Visibility="Collapsed">
<ProgressBar x:Name="TempProgress" Margin="3" IsIndeterminate="True" Visibility="Collapsed"/>
Expand Down
40 changes: 29 additions & 11 deletions Views/DebloatSystemPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,39 @@ private async void UninstallSelectedApp_Click(object sender, RoutedEventArgs e)
}
private static async Task UninstallApps(string appName)
{
if (!appName.Contains("Microsoft.MicrosoftEdge"))
{
/*if (!appName.Contains("Microsoft.MicrosoftEdge"))
{*/
await LogHelper.Log($"Uninstalling: {appName}");
using var script = System.Management.Automation.PowerShell.Create();
script.AddScript($"Get-AppxPackage -AllUsers | Where-Object {{$_.Name -eq '{appName}'}} | Remove-AppxPackage");

var result = await script.InvokeAsync();
var cmdCommand = $"powershell -Command \"Get-AppxPackage -AllUsers | Where-Object {{ $_.Name -eq '{appName}' }} | Remove-AppxPackage\"";

if (script.HadErrors)
var processInfo = new ProcessStartInfo("cmd.exe", $"/c {cmdCommand}")
{
var errorMessage = string.Join(Environment.NewLine, script.Streams.Error.Select(err => err.ToString()));
await LogHelper.LogError(errorMessage);
throw new Exception(errorMessage);
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
};

using var process = new Process { StartInfo = processInfo };
{
process.Start();

var output = await process.StandardOutput.ReadToEndAsync();
var error = await process.StandardError.ReadToEndAsync();

await LogHelper.Log(output);

if (!string.IsNullOrEmpty(error))
{
await LogHelper.LogError(error);
throw new Exception(error);
}
}
}

// Edge removal (will be added soon)

/*}
else
{
var scriptFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", "RemoveEdge.ps1");
Expand All @@ -217,7 +235,7 @@ private static async Task UninstallApps(string appName)
await LogHelper.LogError(errorMessage);
throw new Exception(errorMessage);
}
}
}*/
}

private void ShowAll_Checked(object sender, RoutedEventArgs e)
Expand Down
1 change: 1 addition & 0 deletions Views/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<ComboBoxItem Content="English (US)" Tag="en-us"/>
<ComboBoxItem Content="Français (France)" Tag="fr-fr"/>
<ComboBoxItem Content="العربية (تونس)" Tag="ar-tn"/>
<ComboBoxItem Content="中文 (简体)" Tag="zh-hans"/>
</ComboBox>
</controls:SettingsCard>

Expand Down
2 changes: 1 addition & 1 deletion app.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="0.8.0.0" name="RyTuneX.app"/>
<assemblyIdentity version="0.8.1.0" name="RyTuneX.app"/>
<!--<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
Expand Down

0 comments on commit 066ac20

Please sign in to comment.