Browse Source

fix(.net 3.5): general fixes

master
he3als 4 months ago
parent
commit
96135bca0d
Signed by: he3als GPG Key ID: A0FC52EA5368ECF4
2 changed files with 30 additions and 45 deletions
  1. +30
    -41
      src/Actions/.NET.cs
  2. +0
    -4
      src/Misc.FolderPicker/FolderPicker.cs

+ 30
- 41
src/Actions/.NET.cs View File

@ -52,15 +52,18 @@ namespace amecs.Actions
{
string letter;
var choice = new ChoicePrompt() { Text = "A Windows Setup image must be provided to install .NET 3.5.\r\nWould you like to use a Windows Setup USB/folder instead of an ISO? (Y/N): " }.Start();
var choice = new ChoicePrompt() { Text = "A Windows Setup ISO must be provided to install .NET 3.5.\r\nDo you have a Win USB/folder instead of an ISO? (Y/N): " }.Start();
if (choice == null) return false;
var usingFolder = choice == 0;
if (usingFolder)
{
var dlg = new FolderPicker();
dlg.InputPath = Globals.UserFolder;
if (dlg.ShowDialog(default, false) == false) return false;
if (CheckFileViolation(dlg.ResultPath)) return false;
letter = dlg.ResultPath;
Console.WriteLine(letter);
Console.ReadLine();
}
else
{
@ -71,51 +74,12 @@ namespace amecs.Actions
NativeWindow window = new NativeWindow();
window.AssignHandle(Process.GetCurrentProcess().MainWindowHandle);
Console.WriteLine("a");
if (dialog.ShowDialog(window) == DialogResult.OK)
{
if (CheckFileViolation(dialog.FileName)) return false;
Console.WriteLine();
ConsoleTUI.OpenFrame.WriteCentered("\r\nMounting ISO");
using (new ConsoleUtils.LoadingIndicator(true))
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "PowerShell.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = $"-NoP -C \"(Mount-DiskImage '{file}' -PassThru | Get-Volume).DriveLetter + ':'\"";
startInfo.RedirectStandardOutput = true;
var proc = Process.Start(startInfo);
proc.WaitForExit();
letter = proc.StandardOutput.ReadLine();
}
if (!Directory.Exists(letter + @"\sources\sxs") || !Directory.GetFiles(letter + @"\sources\sxs", "*netfx3*").Any())
{
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "PowerShell.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = $"-NoP -C \"Dismount-DiskImage '{file}'\"";
startInfo.RedirectStandardOutput = true;
var proc = Process.Start(startInfo);
proc.WaitForExit();
} catch (Exception e)
{
}
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("ISO does not contain the required files.", ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt() { AnyKey = true, Text = "Press any key to return to the Menu: " });
return false;
}
}
else
{
@ -123,8 +87,33 @@ namespace amecs.Actions
ConsoleTUI.OpenFrame.Close("\r\nYou must select an ISO.", new ChoicePrompt() {AnyKey = true, Text = "Press any key to return to the Menu: "});
return true;
}
using (new ConsoleUtils.LoadingIndicator(true))
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "PowerShell.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments =
$"-NoP -C \"(Mount-DiskImage '{file}' -PassThru | Get-Volume).DriveLetter + ':\'\"";
startInfo.RedirectStandardOutput = true;
var proc = Process.Start(startInfo);
proc.WaitForExit();
letter = proc.StandardOutput.ReadLine();
}
}
if (!Directory.Exists(letter + @"\sources\sxs") || !Directory.GetFiles(letter + @"\sources\sxs", "*netfx3*").Any())
{
DismountImage();
Console.WriteLine();
ConsoleTUI.OpenFrame.Close("ISO/USB/folder does not contain the required files.", ConsoleColor.Red, Console.BackgroundColor, new ChoicePrompt() { AnyKey = true, Text = "Press any key to return to the Menu: " });
return false;
}
ConsoleTUI.OpenFrame.WriteCentered("\r\nInstalling .NET 3.5");
var topCache = Console.CursorTop;
var leftCache = Console.CursorLeft;


+ 0
- 4
src/Misc.FolderPicker/FolderPicker.cs View File

@ -4,10 +4,6 @@ using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Windows.Interop;
namespace Misc.FolderPicker
{


Loading…
Cancel
Save