diff --git a/src/Actions/.NET.cs b/src/Actions/.NET.cs index 36ab4e7..72d8933 100644 --- a/src/Actions/.NET.cs +++ b/src/Actions/.NET.cs @@ -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; diff --git a/src/Misc.FolderPicker/FolderPicker.cs b/src/Misc.FolderPicker/FolderPicker.cs index 1074d0e..12d04e6 100644 --- a/src/Misc.FolderPicker/FolderPicker.cs +++ b/src/Misc.FolderPicker/FolderPicker.cs @@ -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 {