Skip to content

Commit

Permalink
Added Net 6 functionality 🗻
Browse files Browse the repository at this point in the history
  • Loading branch information
Inestic committed Jun 27, 2022
1 parent 01f70f2 commit dd52f71
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 4 deletions.
2 changes: 2 additions & 0 deletions SophiApp/SophiApp/Customisations/CustomisationConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,8 @@ function MinimizeWindow
internal const byte DIALOG_DETAILED_VALUE = 1;
internal const string DISABLED = "Disabled";
internal const byte DISABLED_VALUE = 0;
internal const string DOTNET_INSTALL_ARGS = "/install /passive /norestart";
internal const string DOTNET_LOG_PATTERN = "Microsoft_Windows_Desktop_Runtime_*.log";
internal const string ENABLED = "Enabled";
internal const byte ENABLED_VALUE = 1;
internal const string ENTHUSIAST_MODE = "EnthusiastMode";
Expand Down
32 changes: 32 additions & 0 deletions SophiApp/SophiApp/Customisations/CustomisationOs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,38 @@ public static void _352(bool _)
}
}

public static void _354(bool _)
{
var temp = Environment.GetEnvironmentVariable(TEMP);
var latestRelease = AppHelper.CloudNet6Version.Releases.Where(release => release.ReleaseVersion == $"{AppHelper.CloudNet6Version.LatestRelease}").First();
var latestRuntime = latestRelease.WindowsDesktop.Files.Where(file => file.Name == "windowsdesktop-runtime-win-x86.exe").First();
var installer = $@"{temp}\{latestRuntime.Url.Substring(latestRuntime.Url.LastIndexOf('/') + 1)}";
WebHelper.Download(latestRuntime.Url, installer);
ProcessHelper.StartWait(installer, DOTNET_INSTALL_ARGS);
FileHelper.TryDeleteFile(installer);
Directory.EnumerateFileSystemEntries(temp, DOTNET_LOG_PATTERN)
.ToList()
.ForEach(log => FileHelper.TryDeleteFile(log));
}

public static void _355(bool _) => DotNetHelper.Uninstall("windowsdesktop-runtime-6.*-win-x86.exe");

public static void _357(bool _)
{
var temp = Environment.GetEnvironmentVariable(TEMP);
var latestRelease = AppHelper.CloudNet6Version.Releases.Where(release => release.ReleaseVersion == $"{AppHelper.CloudNet6Version.LatestRelease}").First();
var latestRuntime = latestRelease.WindowsDesktop.Files.Where(file => file.Name == "windowsdesktop-runtime-win-x64.exe").First();
var installer = $@"{temp}\{latestRuntime.Url.Substring(latestRuntime.Url.LastIndexOf('/') + 1)}";
WebHelper.Download(latestRuntime.Url, installer);
ProcessHelper.StartWait(installer, DOTNET_INSTALL_ARGS);
FileHelper.TryDeleteFile(installer);
Directory.EnumerateFileSystemEntries(temp, DOTNET_LOG_PATTERN)
.ToList()
.ForEach(log => FileHelper.TryDeleteFile(log));
}

public static void _358(bool _) => DotNetHelper.Uninstall("windowsdesktop-runtime-6.*-win-x64.exe");

public static void _500(bool IsChecked)
{
if (IsChecked)
Expand Down
12 changes: 10 additions & 2 deletions SophiApp/SophiApp/Customisations/CustomisationStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,27 +448,35 @@ public static bool _354()
if (HttpHelper.IsOnline)
{
var cloudNetVersion = AppHelper.CloudNet6Version.LatestRelease;
return DotNetHelper.HasInstalled(cloudNetVersion, DotNetRid.Win_x86)
return DotNetHelper.IsInstalled(cloudNetVersion, DotNetRid.Win_x86)
? throw new DotNetInstalledException(cloudNetVersion)
: false;
}

throw new NoInternetConnectionException();
}

public static bool _355() => DotNetHelper.IsInstalled("windowsdesktop-runtime-6.*-win-x86.exe", DotNetRid.Win_x86)
? false
: throw new FileNotExistException("windowsdesktop-runtime-6.*-win-x86.exe");

public static bool _357()
{
if (HttpHelper.IsOnline)
{
var cloudNetVersion = AppHelper.CloudNet6Version.LatestRelease;
return DotNetHelper.HasInstalled(cloudNetVersion, DotNetRid.Win_x64)
return DotNetHelper.IsInstalled(cloudNetVersion, DotNetRid.Win_x64)
? throw new DotNetInstalledException(cloudNetVersion)
: false;
}

throw new NoInternetConnectionException();
}

public static bool _358() => DotNetHelper.IsInstalled("windowsdesktop-runtime-6.*-win-x64.exe", DotNetRid.Win_x86)
? false
: throw new FileNotExistException("windowsdesktop-runtime-6.*-win-x64.exe");

public static bool _500() => HttpHelper.IsOnline
? UwpHelper.PackageExist(UWP_MS_WIN_PHOTOS)
? UwpHelper.PackageExist(_500_UWP_HEVC_VIDEO)
Expand Down
42 changes: 42 additions & 0 deletions SophiApp/SophiApp/Dto/MsNetDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,47 @@ internal class MsNetDto
{
[JsonProperty("latest-release")]
public Version LatestRelease { get; set; }

[JsonProperty("releases")]
public MsNetRelease[] Releases { get; set; }
}

internal class MsNetRelease
{
[JsonProperty("release-date")]
public DateTime ReleaseDate { get; set; }

[JsonProperty("release-version")]
public string ReleaseVersion { get; set; }

[JsonProperty("windowsdesktop")]
public MsNetWindowsDesktop WindowsDesktop { get; set; }
}

internal class MsNetWindowsDesktop
{
[JsonProperty("files")]
public MsNetWindowsDesktopFiles[] Files { get; set; }

[JsonProperty("version")]
public string Version { get; set; }

[JsonProperty("version-display")]
public string VersionDisplay { get; set; }
}

internal class MsNetWindowsDesktopFiles
{
[JsonProperty("hash")]
public string Hash { get; set; }

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("rid")]
public string Rid { get; set; }

[JsonProperty("url")]
public string Url { get; set; }
}
}
16 changes: 14 additions & 2 deletions SophiApp/SophiApp/Helpers/DotNetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ internal class DotNetHelper
{DotNetRid.Win_x86, "win-x86" }, {DotNetRid.Win_x64, "win-x64" }
};

internal static bool HasInstalled(Version version, DotNetRid rid)
internal static bool IsInstalled(Version version, DotNetRid rid)
{
var runtime = $"dotnet-runtime-{version}-{Platform[rid]}.exe";
var runtime = $"windowsdesktop-runtime-{version}-{Platform[rid]}.exe";
return Directory.GetFileSystemEntries(ENVIRONMENT_PACKAGE_CACHE, runtime, SearchOption.AllDirectories)
.Count() == 1;
}

internal static bool IsInstalled(string runtime, DotNetRid rid)
{
return Directory.GetFileSystemEntries(ENVIRONMENT_PACKAGE_CACHE, runtime, SearchOption.AllDirectories)
.Count() == 1;
}

internal static void Uninstall(string runtime)
{
var runtimeFile = Directory.GetFileSystemEntries(ENVIRONMENT_PACKAGE_CACHE, runtime, SearchOption.AllDirectories).First();
ProcessHelper.StartWait(runtimeFile, "/uninstall /passive /norestart");
}
}
}

0 comments on commit dd52f71

Please sign in to comment.