diff --git a/.azure-pipelines/Release Build.yml b/.azure-pipelines/Release Build.yml
new file mode 100644
index 000000000..9479d2575
--- /dev/null
+++ b/.azure-pipelines/Release Build.yml
@@ -0,0 +1,216 @@
+name: Release Build
+jobs:
+- job: Mac_Build
+ displayName: Mac Build
+ timeoutInMinutes: 360
+ pool:
+ vmImage: macos-latest
+ steps:
+
+ - task: InstallSSHKey@0
+ inputs:
+ knownHostsEntry: |
+ github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
+ github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
+ github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
+ sshKeySecureFile: 'pipelines_rsa'
+
+ - checkout: self
+ submodules: recursive
+ clean: true
+ fetchTags: false
+
+ - task: PowerShell@2
+ displayName: Add CurrentVersion Variable
+ inputs:
+ targetType: inline
+ script: |
+ $VersionString = git show -s --format=%ci $(Build.SourceVersion)
+ $VersionDate = [DateTimeOffset]::Parse($VersionString)
+
+ $Year = $VersionDate.Year.ToString()
+ $Month = $VersionDate.Month.ToString().PadLeft(2, "0")
+ $Day = $VersionDate.Day.ToString().PadLeft(2, "0")
+ $Hour = $VersionDate.Hour.ToString().PadLeft(2, "0")
+ $Minute = $VersionDate.Minute.ToString().PadLeft(2, "0")
+ $CurrentVersion = "$Year.$Month.$Day.$Hour$Minute"
+
+ [System.Console]::WriteLine("##vso[task.setvariable variable=CurrentVersion]$CurrentVersion")
+
+ Write-Host "Setting current version to $CurrentVersion."
+
+ - task: UseDotNet@2
+ displayName: Use .NET Core sdk 6.x
+ inputs:
+ version: 6.x
+
+ - task: DotNetCoreCLI@2
+ displayName: dotnet publish x64
+ inputs:
+ command: publish
+ publishWebProjects: false
+ projects: '**/Agent.csproj'
+ arguments: -c $(BuildConfiguration) -r osx-x64 -o "$(Build.SourcesDirectory)/Agent/bin/publish" /p:Version=$(CurrentVersion) /p:FileVersion=$(CurrentVersion)
+ zipAfterPublish: false
+ modifyOutputPath: false
+
+ - task: PowerShell@2
+ displayName: PowerShell Script
+ inputs:
+ targetType: inline
+ script: |
+ Compress-Archive -Path "$(Build.SourcesDirectory)/Agent/bin/publish/*" -DestinationPath "$(Build.SourcesDirectory)/Agent/bin/Remotely-MacOS-x64.zip" -Force
+
+ - task: PublishPipelineArtifact@1
+ displayName: Publish macOS x64 Agent
+ inputs:
+ path: $(Build.SourcesDirectory)/Agent/bin/Remotely-MacOS-x64.zip
+ artifactName: Mac-x64-Agent
+
+- job: Windows_Build
+ displayName: Windows Build
+ timeoutInMinutes: 360
+ dependsOn: Mac_Build
+ pool:
+ vmImage: windows-latest
+
+ steps:
+ - task: InstallSSHKey@0
+ inputs:
+ knownHostsEntry: |
+ github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
+ github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
+ github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
+ sshKeySecureFile: 'pipelines_rsa'
+
+ - checkout: self
+ submodules: recursive
+ clean: true
+ fetchTags: false
+
+ - task: VisualStudioTestPlatformInstaller@1
+ displayName: Visual Studio Test Platform Installer
+
+ - task: NodeTool@0
+ inputs:
+ versionSource: 'spec'
+ versionSpec: '6.x'
+ checkLatest: true
+
+ - task: DownloadPipelineArtifact@2
+ displayName: Download macOS x64 Agent
+ inputs:
+ artifact: Mac-x64-Agent
+ path: $(Build.SourcesDirectory)\Server\wwwroot\Content\
+
+ - task: PowerShell@2
+ displayName: Add CurrentVersion Variable
+ inputs:
+ targetType: inline
+ script: |
+ $VersionString = git show -s --format=%ci $(Build.SourceVersion)
+ $VersionDate = [DateTimeOffset]::Parse($VersionString)
+
+ $Year = $VersionDate.Year.ToString()
+ $Month = $VersionDate.Month.ToString().PadLeft(2, "0")
+ $Day = $VersionDate.Day.ToString().PadLeft(2, "0")
+ $Hour = $VersionDate.Hour.ToString().PadLeft(2, "0")
+ $Minute = $VersionDate.Minute.ToString().PadLeft(2, "0")
+ $CurrentVersion = "$Year.$Month.$Day.$Hour$Minute"
+
+ [System.Console]::WriteLine("##vso[task.setvariable variable=CurrentVersion]$CurrentVersion")
+
+ Write-Host "Setting current version to $CurrentVersion."
+
+ - task: NuGetToolInstaller@1
+ displayName: 'Use NuGet'
+
+ - task: NuGetCommand@2
+ displayName: NuGet restore Agent.Installer.Win
+ inputs:
+ solution: Agent.Installer.Win/packages.config
+ packagesDirectory: $(Build.SourcesDirectory)\packages
+
+ - task: UseDotNet@2
+ displayName: Use .NET Core sdk 6.x
+ inputs:
+ version: 6.x
+
+ - task: DotNetCoreCLI@2
+ displayName: dotnet restore
+ inputs:
+ command: restore
+ projects: '**/*.csproj'
+
+ - task: DotNetCoreCLI@2
+ displayName: dotnet test
+ inputs:
+ command: test
+ projects: Tests\Tests.csproj
+
+ - task: PowerShell@2
+ displayName: Create Code Signing Cert
+ env:
+ SigningCertBase64: $(CODE_SIGNING_CERT_BASE64)
+ inputs:
+ targetType: inline
+ script: |
+ if (!$env:SigningCertBase64) {
+ Write-Host "CODE_SIGNING_CERT_BASE64 variable is empty. Skipping cert creation."
+ return
+ }
+ $CertBytes = [System.Convert]::FromBase64String($env:SigningCertBase64)
+ [System.IO.File]::WriteAllBytes("$(Build.SourcesDirectory)\Utilities\CodeSigningCert.pfx", $CertBytes)
+
+ - task: PowerShell@2
+ displayName: Publish.ps1
+ inputs:
+ filePath: Utilities/Publish.ps1
+ arguments: -CertificatePath "$(Build.SourcesDirectory)\Utilities\CodeSigningCert.pfx" -CertificatePassword "$(SIGNING_CERT_PASSWORD)" -CurrentVersion "$(CurrentVersion)"
+ failOnStderr: true
+ workingDirectory: Utilities
+
+ # The MSBuild TypeScript task doesn't compiled the TS
+ # files without this build step before publishing.
+ - task: DotNetCoreCLI@2
+ inputs:
+ command: 'build'
+ projects: '$(Build.SourcesDirectory)/Server/Server.csproj'
+ arguments: '-r linux-x64 -c Release'
+
+ - task: DotNetCoreCLI@2
+ displayName: dotnet publish linux-x64
+ inputs:
+ command: publish
+ publishWebProjects: false
+ projects: '$(Build.SourcesDirectory)/Server/Server.csproj'
+ arguments: /p:Version=$(CurrentVersion) /p:FileVersion=$(CurrentVersion) --configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)\linux-x64 --runtime linux-x64
+
+
+ - task: PowerShell@2
+ displayName: Write Version File
+ inputs:
+ targetType: inline
+ script: |
+ Write-Host "Adding Version to File: $(CurrentVersion)"
+ # This is used in the Release.
+ New-Item -ItemType File -Value "$(CurrentVersion)" -Path "$(build.artifactstagingdirectory)\Version.txt" -Force
+
+ - task: PowerShell@2
+ displayName: Copy Docker Files
+ inputs:
+ targetType: inline
+ script: |
+ Copy-Item -Path "$(Build.SourcesDirectory)\Server\Dockerfile" -Destination "$(build.artifactstagingdirectory)\Dockerfile"
+ Copy-Item -Path "$(Build.SourcesDirectory)\Server\DockerMain.sh" -Destination "$(build.artifactstagingdirectory)\DockerMain.sh"
+
+ - task: PublishBuildArtifacts@1
+ displayName: Publish Artifact
+ condition: succeededOrFailed()
+ inputs:
+ PathtoPublish: $(build.artifactstagingdirectory)
+ ArtifactName: Server
+ TargetPath: '\\my\share\$(Build.DefinitionName)\$(Build.BuildNumber)'
+
+ - task: PostBuildCleanup@3
+ displayName: Clean Agent Directories
diff --git a/Agent.Installer.Win/Agent.Installer.Win.csproj b/Agent.Installer.Win/Agent.Installer.Win.csproj
index ec6d669c7..de9ce28ba 100644
--- a/Agent.Installer.Win/Agent.Installer.Win.csproj
+++ b/Agent.Installer.Win/Agent.Installer.Win.csproj
@@ -132,9 +132,11 @@
Models\DeviceSetupOptions.cs
+
+
-
+
diff --git a/Agent.Installer.Win/Models/EmbeddedServerData.cs b/Agent.Installer.Win/Models/EmbeddedServerData.cs
new file mode 100644
index 000000000..b4e768fc8
--- /dev/null
+++ b/Agent.Installer.Win/Models/EmbeddedServerData.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Remotely.Agent.Installer.Models
+{
+ [DataContract]
+ public class EmbeddedServerData
+ {
+ public EmbeddedServerData(Uri serverUrl, string organizationId)
+ {
+ ServerUrl = serverUrl;
+ OrganizationId = organizationId;
+ }
+
+ private EmbeddedServerData() { }
+
+ public static EmbeddedServerData Empty { get; } = new EmbeddedServerData();
+
+ [DataMember]
+ public string OrganizationId { get; }
+
+ [DataMember]
+ public Uri ServerUrl { get; }
+ }
+}
diff --git a/Agent.Installer.Win/Properties/AssemblyInfo.cs b/Agent.Installer.Win/Properties/AssemblyInfo.cs
index d8aa9c65e..08bc29a9b 100644
--- a/Agent.Installer.Win/Properties/AssemblyInfo.cs
+++ b/Agent.Installer.Win/Properties/AssemblyInfo.cs
@@ -8,9 +8,9 @@
[assembly: AssemblyTitle("Remotely Installer")]
[assembly: AssemblyDescription("An installer for the Remotely service, which provides unattended remote access and remote scripting.")]
[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Translucency Software")]
+[assembly: AssemblyCompany("Immense Networks")]
[assembly: AssemblyProduct("Remotely Installer")]
-[assembly: AssemblyCopyright("Copyright © 2020 Translucency Software")]
+[assembly: AssemblyCopyright("Copyright © 2020 Immense Networks")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/Agent.Installer.Win/Services/EmbeddedServerDataReader.cs b/Agent.Installer.Win/Services/EmbeddedServerDataReader.cs
new file mode 100644
index 000000000..87a604a1a
--- /dev/null
+++ b/Agent.Installer.Win/Services/EmbeddedServerDataReader.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.Serialization.Json;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web.Script.Serialization;
+using Remotely.Agent.Installer.Models;
+using Remotely.Agent.Installer.Win.Utilities;
+using Remotely.Shared;
+
+namespace Remotely.Agent.Installer.Win.Services
+{
+ internal class EmbeddedServerDataReader
+ {
+ private readonly JavaScriptSerializer _serializer = new JavaScriptSerializer();
+
+ public Task TryGetEmbeddedData(string filePath)
+ {
+ try
+ {
+ if (!File.Exists(filePath))
+ {
+ throw new Exception($"File path does not exist: {filePath}");
+ }
+
+ using (var fs = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
+ {
+ var result = SearchBuffer(fs, AppConstants.EmbeddedImmySignature);
+ if (result == -1)
+ {
+ throw new Exception("Signature not found in file buffer.");
+ }
+
+ fs.Seek(result + AppConstants.EmbeddedImmySignature.Length, SeekOrigin.Begin);
+ using (var reader = new BinaryReader(fs))
+ {
+ var serializedData = reader.ReadString();
+ return Task.FromResult(_serializer.Deserialize(serializedData));
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.Write(ex);
+ return Task.FromResult(EmbeddedServerData.Empty);
+ }
+ }
+
+ private long SearchBuffer(FileStream fileStream, byte[] matchPattern)
+ {
+ var matchSize = matchPattern.Length;
+ var limit = fileStream.Length - matchSize;
+
+ for (var i = 0; i <= limit; i++)
+ {
+ var k = 0;
+
+ for (; k < matchSize; k++)
+ {
+ if (matchPattern[k] != fileStream.ReadByte())
+ {
+ break;
+ }
+ }
+
+ if (k == matchSize)
+ {
+ return fileStream.Position - matchSize;
+ }
+ }
+ return -1;
+ }
+ }
+}
diff --git a/Agent.Installer.Win/Services/InstallerService.cs b/Agent.Installer.Win/Services/InstallerService.cs
index db82de881..fcb27c9eb 100644
--- a/Agent.Installer.Win/Services/InstallerService.cs
+++ b/Agent.Installer.Win/Services/InstallerService.cs
@@ -22,12 +22,13 @@ namespace Remotely.Agent.Installer.Win.Services
{
public class InstallerService
{
+ private readonly string _installPath = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), "Program Files", "Remotely");
+ private readonly string _platform = Environment.Is64BitOperatingSystem ? "x64" : "x86";
+ private readonly JavaScriptSerializer _serializer = new JavaScriptSerializer();
+
public event EventHandler ProgressMessageChanged;
public event EventHandler ProgressValueChanged;
- private string InstallPath => Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), "Program Files", "Remotely");
- private string Platform => Environment.Is64BitOperatingSystem ? "x64" : "x86";
- private JavaScriptSerializer Serializer { get; } = new JavaScriptSerializer();
public async Task Install(string serverUrl,
string organizationId,
string deviceGroup,
@@ -55,9 +56,9 @@ public async Task Install(string serverUrl,
await DownloadRemotelyAgent(serverUrl);
- FileIO.WriteAllText(Path.Combine(InstallPath, "ConnectionInfo.json"), Serializer.Serialize(connectionInfo));
+ FileIO.WriteAllText(Path.Combine(_installPath, "ConnectionInfo.json"), _serializer.Serialize(connectionInfo));
- FileIO.Copy(Assembly.GetExecutingAssembly().Location, Path.Combine(InstallPath, "Remotely_Installer.exe"));
+ FileIO.Copy(Assembly.GetExecutingAssembly().Location, Path.Combine(_installPath, "Remotely_Installer.exe"));
await CreateDeviceOnServer(connectionInfo.DeviceID, serverUrl, deviceGroup, deviceAlias, organizationId);
@@ -97,7 +98,7 @@ public async Task Uninstall()
ProgressMessageChanged?.Invoke(this, "Deleting files.");
ClearInstallDirectory();
- ProcessEx.StartHidden("cmd.exe", $"/c timeout 5 & rd /s /q \"{InstallPath}\"");
+ ProcessEx.StartHidden("cmd.exe", $"/c timeout 5 & rd /s /q \"{_installPath}\"");
ProcessEx.StartHidden("netsh", "advfirewall firewall delete rule name=\"Remotely Desktop Unattended\"").WaitForExit();
@@ -114,14 +115,14 @@ public async Task Uninstall()
private void AddFirewallRule()
{
- var desktopExePath = Path.Combine(InstallPath, "Desktop", "Remotely_Desktop.exe");
+ var desktopExePath = Path.Combine(_installPath, "Desktop", "Remotely_Desktop.exe");
ProcessEx.StartHidden("netsh", "advfirewall firewall delete rule name=\"Remotely Desktop Unattended\"").WaitForExit();
ProcessEx.StartHidden("netsh", $"advfirewall firewall add rule name=\"Remotely Desktop Unattended\" program=\"{desktopExePath}\" protocol=any dir=in enable=yes action=allow description=\"The agent that allows screen sharing and remote control for Remotely.\"").WaitForExit();
}
private void BackupDirectory()
{
- if (Directory.Exists(InstallPath))
+ if (Directory.Exists(_installPath))
{
Logger.Write("Backing up current installation.");
ProgressMessageChanged?.Invoke(this, "Backing up current installation.");
@@ -130,7 +131,7 @@ private void BackupDirectory()
{
FileIO.Delete(backupPath);
}
- ZipFile.CreateFromDirectory(InstallPath, backupPath, CompressionLevel.Fastest, false);
+ ZipFile.CreateFromDirectory(_installPath, backupPath, CompressionLevel.Fastest, false);
}
}
@@ -148,9 +149,9 @@ private bool CheckIsAdministrator()
private void ClearInstallDirectory()
{
- if (Directory.Exists(InstallPath))
+ if (Directory.Exists(_installPath))
{
- foreach (var entry in Directory.GetFileSystemEntries(InstallPath))
+ foreach (var entry in Directory.GetFileSystemEntries(_installPath))
{
try
{
@@ -196,7 +197,7 @@ private async Task CreateDeviceOnServer(string deviceUuid,
using (var rs = await wr.GetRequestStreamAsync())
using (var sw = new StreamWriter(rs))
{
- await sw.WriteAsync(Serializer.Serialize(setupOptions));
+ await sw.WriteAsync(_serializer.Serialize(setupOptions));
}
using (var response = await wr.GetResponseAsync() as HttpWebResponse)
{
@@ -218,10 +219,10 @@ private async Task CreateDeviceOnServer(string deviceUuid,
private void CreateSupportShortcut(string serverUrl, string deviceUuid, bool createSupportShortcut)
{
var shell = new WshShell();
- var shortcutLocation = Path.Combine(InstallPath, "Get Support.lnk");
+ var shortcutLocation = Path.Combine(_installPath, "Get Support.lnk");
var shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);
shortcut.Description = "Get IT support";
- shortcut.IconLocation = Path.Combine(InstallPath, "Remotely_Agent.exe");
+ shortcut.IconLocation = Path.Combine(_installPath, "Remotely_Agent.exe");
shortcut.TargetPath = serverUrl.TrimEnd('/') + $"/GetSupport?deviceID={deviceUuid}";
shortcut.Save();
@@ -234,19 +235,19 @@ private void CreateSupportShortcut(string serverUrl, string deviceUuid, bool cre
}
private void CreateUninstallKey()
{
- var version = FileVersionInfo.GetVersionInfo(Path.Combine(InstallPath, "Remotely_Agent.exe"));
+ var version = FileVersionInfo.GetVersionInfo(Path.Combine(_installPath, "Remotely_Agent.exe"));
var baseKey = GetRegistryBaseKey();
var remotelyKey = baseKey.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Remotely", true);
- remotelyKey.SetValue("DisplayIcon", Path.Combine(InstallPath, "Remotely_Agent.exe"));
+ remotelyKey.SetValue("DisplayIcon", Path.Combine(_installPath, "Remotely_Agent.exe"));
remotelyKey.SetValue("DisplayName", "Remotely");
remotelyKey.SetValue("DisplayVersion", version.FileVersion);
remotelyKey.SetValue("InstallDate", DateTime.Now.ToShortDateString());
- remotelyKey.SetValue("Publisher", "Translucency Software");
+ remotelyKey.SetValue("Publisher", "Immense Networks");
remotelyKey.SetValue("VersionMajor", version.FileMajorPart.ToString(), RegistryValueKind.DWord);
remotelyKey.SetValue("VersionMinor", version.FileMinorPart.ToString(), RegistryValueKind.DWord);
- remotelyKey.SetValue("UninstallString", Path.Combine(InstallPath, "Remotely_Installer.exe -uninstall -quiet"));
- remotelyKey.SetValue("QuietUninstallString", Path.Combine(InstallPath, "Remotely_Installer.exe -uninstall -quiet"));
+ remotelyKey.SetValue("UninstallString", Path.Combine(_installPath, "Remotely_Installer.exe -uninstall -quiet"));
+ remotelyKey.SetValue("QuietUninstallString", Path.Combine(_installPath, "Remotely_Installer.exe -uninstall -quiet"));
}
private async Task DownloadRemotelyAgent(string serverUrl)
@@ -268,7 +269,7 @@ private async Task DownloadRemotelyAgent(string serverUrl)
ProgressValueChanged?.Invoke(this, args.ProgressPercentage);
};
- await client.DownloadFileTaskAsync($"{serverUrl}/Content/Remotely-Win10-{Platform}.zip", targetFile);
+ await client.DownloadFileTaskAsync($"{serverUrl}/Content/Remotely-Win10-{_platform}.zip", targetFile);
}
}
@@ -281,17 +282,17 @@ private async Task DownloadRemotelyAgent(string serverUrl)
Directory.Delete(tempDir, true);
}
- Directory.CreateDirectory(InstallPath);
- while (!Directory.Exists(InstallPath))
+ Directory.CreateDirectory(_installPath);
+ while (!Directory.Exists(_installPath))
{
await Task.Delay(10);
}
- var wr = WebRequest.CreateHttp($"{serverUrl}/Content/Remotely-Win10-{Platform}.zip");
+ var wr = WebRequest.CreateHttp($"{serverUrl}/Content/Remotely-Win10-{_platform}.zip");
wr.Method = "Head";
using (var response = (HttpWebResponse)await wr.GetResponseAsync())
{
- FileIO.WriteAllText(Path.Combine(InstallPath, "etag.txt"), response.Headers["ETag"]);
+ FileIO.WriteAllText(Path.Combine(_installPath, "etag.txt"), response.Headers["ETag"]);
}
ZipFile.ExtractToDirectory(targetFile, tempDir);
@@ -304,11 +305,11 @@ private async Task DownloadRemotelyAgent(string serverUrl)
var entry = fileSystemEntries[i];
if (FileIO.Exists(entry))
{
- FileIO.Copy(entry, Path.Combine(InstallPath, Path.GetFileName(entry)), true);
+ FileIO.Copy(entry, Path.Combine(_installPath, Path.GetFileName(entry)), true);
}
else if (Directory.Exists(entry))
{
- FileSystem.CopyDirectory(entry, Path.Combine(InstallPath, new DirectoryInfo(entry).Name), true);
+ FileSystem.CopyDirectory(entry, Path.Combine(_installPath, new DirectoryInfo(entry).Name), true);
}
await Task.Delay(1);
}
@@ -323,10 +324,10 @@ private async Task DownloadRemotelyAgent(string serverUrl)
private ConnectionInfo GetConnectionInfo(string organizationId, string serverUrl, string deviceUuid)
{
ConnectionInfo connectionInfo;
- var connectionInfoPath = Path.Combine(InstallPath, "ConnectionInfo.json");
+ var connectionInfoPath = Path.Combine(_installPath, "ConnectionInfo.json");
if (FileIO.Exists(connectionInfoPath))
{
- connectionInfo = Serializer.Deserialize(FileIO.ReadAllText(connectionInfoPath));
+ connectionInfo = _serializer.Deserialize(FileIO.ReadAllText(connectionInfoPath));
connectionInfo.ServerVerificationToken = null;
}
else
@@ -370,7 +371,7 @@ private void InstallService()
var serv = ServiceController.GetServices().FirstOrDefault(ser => ser.ServiceName == "Remotely_Service");
if (serv == null)
{
- var command = new string[] { "/assemblypath=" + Path.Combine(InstallPath, "Remotely_Agent.exe") };
+ var command = new string[] { "/assemblypath=" + Path.Combine(_installPath, "Remotely_Agent.exe") };
var context = new InstallContext("", command);
var serviceInstaller = new ServiceInstaller()
{
@@ -406,7 +407,7 @@ private void RestoreBackup()
{
Logger.Write("Restoring backup.");
ClearInstallDirectory();
- ZipFile.ExtractToDirectory(backupPath, InstallPath);
+ ZipFile.ExtractToDirectory(backupPath, _installPath);
var serv = ServiceController.GetServices().FirstOrDefault(ser => ser.ServiceName == "Remotely_Service");
if (serv?.Status != ServiceControllerStatus.Running)
{
diff --git a/Agent.Installer.Win/Services/Executor.cs b/Agent.Installer.Win/Services/RelayCommand.cs
similarity index 52%
rename from Agent.Installer.Win/Services/Executor.cs
rename to Agent.Installer.Win/Services/RelayCommand.cs
index 33d39bf2e..eb14f35d7 100644
--- a/Agent.Installer.Win/Services/Executor.cs
+++ b/Agent.Installer.Win/Services/RelayCommand.cs
@@ -3,12 +3,16 @@
namespace Remotely.Agent.Installer.Win.Services
{
- public class Executor : ICommand
+ public class RelayCommand : ICommand
{
- public Executor(Action