From e4291713eb5bfc75acba667e03839d6fa1df6519 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Thu, 23 Apr 2020 09:20:24 -0700 Subject: [PATCH] Update publish profiles. --- .../ViewModels/MainWindowViewModel.cs | 2 +- Desktop.Win.Wrapper/MainWindow.xaml.cs | 62 +++++++++++++++---- .../PublishProfiles/wrapper-x64.pubxml | 17 +++++ .../{Wrapper.pubxml => wrapper-x86.pubxml} | 2 +- Server/Pages/Agents.cshtml | 8 +-- Utilities/Publish.ps1 | 38 ++++++++---- 6 files changed, 99 insertions(+), 30 deletions(-) create mode 100644 Desktop.Win/Properties/PublishProfiles/wrapper-x64.pubxml rename Desktop.Win/Properties/PublishProfiles/{Wrapper.pubxml => wrapper-x86.pubxml} (89%) 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 @@ + + + + + FileSystem + Release + x64 + netcoreapp3.1 + bin\Release\win-x64\publish\ + false + win10-x64 + False + False + + \ No newline at end of file diff --git a/Desktop.Win/Properties/PublishProfiles/Wrapper.pubxml b/Desktop.Win/Properties/PublishProfiles/wrapper-x86.pubxml similarity index 89% rename from Desktop.Win/Properties/PublishProfiles/Wrapper.pubxml rename to Desktop.Win/Properties/PublishProfiles/wrapper-x86.pubxml index e2ceb2d7..f07c72ca 100644 --- a/Desktop.Win/Properties/PublishProfiles/Wrapper.pubxml +++ b/Desktop.Win/Properties/PublishProfiles/wrapper-x86.pubxml @@ -8,7 +8,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. Release x86 netcoreapp3.1 - bin\x64\Release\publish\ + bin\Release\win-x86\publish\ false win10-x86 False diff --git a/Server/Pages/Agents.cshtml b/Server/Pages/Agents.cshtml index bbbc3763..ca5fafeb 100644 --- a/Server/Pages/Agents.cshtml +++ b/Server/Pages/Agents.cshtml @@ -9,20 +9,20 @@
Instant desktop sharing. No account required.
- @*
+
Windows (64-Bit)

Download:
Windows EXE

-
*@ +
-
Windows (64/32-Bit)
+
Windows (32-Bit)

Download:
- Windows EXE + Windows EXE

diff --git a/Utilities/Publish.ps1 b/Utilities/Publish.ps1 index 1e5427c6..1213fb77 100644 --- a/Utilities/Publish.ps1 +++ b/Utilities/Publish.ps1 @@ -80,7 +80,7 @@ Set-Content -Path "$Root\Server\CurrentVersion.txt" -Value $CurrentVersion.Trim( if ($Hostname.Length -gt 0) { Replace-LineInFile -FilePath "$Root\Desktop.Win\Services\Config.cs" -MatchPattern "public string Host " -ReplaceLineWith "public string Host { get; set; } = `"$($Hostname)`";" -MaxCount 1 Replace-LineInFile -FilePath "$Root\Desktop.Linux\Services\Config.cs" -MatchPattern "public string Host " -ReplaceLineWith "public string Host { get; set; } = `"$($Hostname)`";" -MaxCount 1 - Replace-LineInFile -FilePath "$Root\Agent.Installer.Win\ViewModels\MainWindowViewModel.cs" -MatchPattern "private string serverUrl;" -ReplaceLineWith "private string serverUrl = `"$($Hostname)`";" -MaxCount 1 + Replace-LineInFile -FilePath "$Root\Agent.Installer.Win\ViewModels\MainWindowViewModel.cs" -MatchPattern "private string serverUrl" -ReplaceLineWith "private string serverUrl = `"$($Hostname)`";" -MaxCount 1 } else { Write-Host "`nWARNING: No hostname parameter was specified. The server name will need to be entered manually in the desktop client.`n" -ForegroundColor DarkYellow @@ -122,26 +122,38 @@ dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion -p:Publ # Publish Windows ScreenCaster (64-bit) dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion -p:PublishProfile=win-x64 --configuration Release "$Root\ScreenCast.Win" + # Publish Windows GUI App (64-bit) -#dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion -p:PublishProfile=win-x64 --configuration Release "$Root\Desktop.Win" - -#if ($SignAssemblies) { -# &"$Root\Utilities\signtool.exe" sign /f "$CertificatePath" /p $CertificatePassword /t http://timestamp.digicert.com "$Root\Server\wwwroot\Downloads\Win-x64\Remotely_Desktop.exe" -#} - -# Publish Windows GUI App (32-bit) -dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion -p:PublishProfile=Wrapper --configuration Release "$Root\Desktop.Win" +dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion -p:PublishProfile=wrapper-x64 --configuration Release "$Root\Desktop.Win" if (Test-Path -Path "$Root\Desktop.Win.Wrapper\Remotely_Desktop.zip"){ Remove-Item -Path "$Root\Desktop.Win.Wrapper\Remotely_Desktop.zip" -Force } -Get-ChildItem -Path "$Root\Desktop.Win\bin\x64\Release\publish\" | ForEach-Object { +Get-ChildItem -Path "$Root\Desktop.Win\bin\Release\win-x64\publish\" | ForEach-Object { Compress-Archive -Path $_.FullName -DestinationPath "$Root\Desktop.Win.Wrapper\Remotely_Desktop.zip" -Update } -&"$MSBuildPath" "$Root\Desktop.Win.Wrapper" /t:Build /p:Configuration=Release /p:Platform=AnyCPU /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion + +&"$MSBuildPath" "$Root\Desktop.Win.Wrapper" /t:Build /p:Configuration=Release /p:Platform=x64 /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion if ($SignAssemblies) { - &"$Root\Utilities\signtool.exe" sign /f "$CertificatePath" /p $CertificatePassword /t http://timestamp.digicert.com "$Root\Desktop.Win.Wrapper\bin\Release\Remotely_Desktop.exe" + &"$Root\Utilities\signtool.exe" sign /f "$CertificatePath" /p $CertificatePassword /t http://timestamp.digicert.com "$Root\Desktop.Win.Wrapper\bin\x64\Release\Remotely_Desktop.exe" } -Copy-Item -Path "$Root\Desktop.Win.Wrapper\bin\Release\Remotely_Desktop.exe" -Destination "$Root\Server\wwwroot\Downloads\Remotely_Desktop.exe" -Force +Copy-Item -Path "$Root\Desktop.Win.Wrapper\bin\x64\Release\Remotely_Desktop.exe" -Destination "$Root\Server\wwwroot\Downloads\Win-x64\Remotely_Desktop.exe" -Force + + +# Publish Windows GUI App (32-bit) +dotnet publish /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion -p:PublishProfile=wrapper-x86 --configuration Release "$Root\Desktop.Win" +if (Test-Path -Path "$Root\Desktop.Win.Wrapper\Remotely_Desktop.zip"){ + Remove-Item -Path "$Root\Desktop.Win.Wrapper\Remotely_Desktop.zip" -Force +} +Get-ChildItem -Path "$Root\Desktop.Win\bin\Release\win-x86\publish\" | ForEach-Object { + Compress-Archive -Path $_.FullName -DestinationPath "$Root\Desktop.Win.Wrapper\Remotely_Desktop.zip" -Update +} + +&"$MSBuildPath" "$Root\Desktop.Win.Wrapper" /t:Build /p:Configuration=Release /p:Platform=x86 /p:Version=$CurrentVersion /p:FileVersion=$CurrentVersion +if ($SignAssemblies) { + &"$Root\Utilities\signtool.exe" sign /f "$CertificatePath" /p $CertificatePassword /t http://timestamp.digicert.com "$Root\Desktop.Win.Wrapper\bin\x86\Release\Remotely_Desktop.exe" +} +Copy-Item -Path "$Root\Desktop.Win.Wrapper\bin\x86\Release\Remotely_Desktop.exe" -Destination "$Root\Server\wwwroot\Downloads\Win-x86\Remotely_Desktop.exe" -Force + # Build installer. &"$MSBuildPath" "$Root\Agent.Installer.Win" /t:Restore