diff --git a/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs b/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs
index 1a6a431e..04165c59 100644
--- a/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs
+++ b/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs
@@ -25,7 +25,7 @@ namespace Remotely.Agent.Installer.Win.ViewModels
private int progress;
- private string serverUrl = "";
+ private string serverUrl;
private string statusMessage;
diff --git a/Desktop.Win.Wrapper/MainWindow.xaml.cs b/Desktop.Win.Wrapper/MainWindow.xaml.cs
index b9c148a6..ba6ea447 100644
--- a/Desktop.Win.Wrapper/MainWindow.xaml.cs
+++ b/Desktop.Win.Wrapper/MainWindow.xaml.cs
@@ -25,7 +25,9 @@ namespace Remotely.Desktop.Win.Wrapper
///
public partial class MainWindow : Window
{
- private readonly string tempDir = Directory.CreateDirectory(PathIO.Combine(PathIO.GetTempPath(), "Remotely_Desktop")).FullName;
+ private static readonly string baseDir = Directory.CreateDirectory(PathIO.Combine(PathIO.GetTempPath(), "Remotely_Desktop")).FullName;
+ private string tempDir;
+
public MainWindow()
{
InitializeComponent();
@@ -46,19 +48,42 @@ namespace Remotely.Desktop.Win.Wrapper
DragMove();
}
- private void Window_Loaded(object sender, RoutedEventArgs e)
+ private async void Window_Loaded(object sender, RoutedEventArgs e)
{
- ExtractRemotely();
- ExtractInstallScript();
- RunInstallScript();
+ StatusText.Text = "Extracting files...";
+ await Task.Run(CleanupOldFiles);
+ tempDir = Directory.CreateDirectory(PathIO.Combine(baseDir, Guid.NewGuid().ToString())).FullName;
+ await Task.Run(ExtractRemotely);
+ await Task.Run(ExtractInstallScript);
+ StatusText.Text = "Updating .NET Core runtime...";
+ await Task.Run(RunInstallScript);
Close();
}
+ private void CleanupOldFiles()
+ {
+ foreach (var fse in Directory.GetFileSystemEntries(baseDir))
+ {
+ try
+ {
+ if (Directory.Exists(fse))
+ {
+ Directory.Delete(fse, true);
+ }
+ else if (File.Exists(fse))
+ {
+ File.Delete(fse);
+ }
+ }
+ catch { }
+
+ }
+ }
+
private void ExtractRemotely()
{
try
{
- StatusText.Text = "Extracting files...";
var zipPath = PathIO.Combine(tempDir, "Remotely_Desktop.zip");
using (var mrs = Assembly.GetExecutingAssembly()
.GetManifestResourceStream("Remotely.Desktop.Win.Wrapper.Remotely_Desktop.zip"))
@@ -70,23 +95,34 @@ namespace Remotely.Desktop.Win.Wrapper
}
ZipFile.ExtractToDirectory(zipPath, tempDir);
}
- catch { }
+ catch (Exception ex)
+ {
+ MessageBox.Show("An error occured while extracting files. Error: " +
+ Environment.NewLine + Environment.NewLine + ex.Message, "Error",
+ MessageBoxButton.OK,
+ MessageBoxImage.Error);
+ }
}
private void RunInstallScript()
{
try
{
- StatusText.Text = "Updating .NET Core runtime...";
var installPath = PathIO.Combine(tempDir, "Install.ps1");
Process.Start(new ProcessStartInfo()
{
FileName = "powershell.exe",
Arguments = $"-executionpolicy bypass -f \"{installPath}\"",
WindowStyle = ProcessWindowStyle.Hidden
- });
+ }).WaitForExit();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("An error occured while updating .NET Core. Error: " +
+ Environment.NewLine + Environment.NewLine + ex.Message, "Error",
+ MessageBoxButton.OK,
+ MessageBoxImage.Error);
}
- catch { }
}
private void ExtractInstallScript()
@@ -103,7 +139,11 @@ namespace Remotely.Desktop.Win.Wrapper
}
}
}
- catch { }
+ catch (Exception ex)
+ {
+ MessageBox.Show("An error occured while extracting files. Error: " +
+ Environment.NewLine + Environment.NewLine + ex.Message);
+ }
}
}
}
diff --git a/Desktop.Win/Properties/PublishProfiles/wrapper-x64.pubxml b/Desktop.Win/Properties/PublishProfiles/wrapper-x64.pubxml
new file mode 100644
index 00000000..fb66c526
--- /dev/null
+++ b/Desktop.Win/Properties/PublishProfiles/wrapper-x64.pubxml
@@ -0,0 +1,17 @@
+
+
+
Download:
Windows EXE