Skip to content

Commit

Permalink
Merge pull request #814 from immense/feature/update-to-net8
Browse files Browse the repository at this point in the history
Update to .NET 8.
  • Loading branch information
bitbound authored Feb 22, 2024
2 parents e3692c7 + ea78f46 commit 646412b
Show file tree
Hide file tree
Showing 254 changed files with 8,491 additions and 4,141 deletions.
78 changes: 5 additions & 73 deletions .azure-pipelines/Release Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,9 @@ pr:
- master

jobs:
- job: Mac_Build
displayName: Mac Build
- job: Build
displayName: 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)
$CurrentVersion = $VersionDate.ToString("yyyy.MM.dd.HHmm")
[System.Console]::WriteLine("##vso[task.setvariable variable=CurrentVersion]$CurrentVersion")
Write-Host "Setting current version to $CurrentVersion."
- task: UseDotNet@2
displayName: Use .NET SDK
inputs:
version: 7.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

Expand All @@ -89,12 +27,6 @@ jobs:

- task: VisualStudioTestPlatformInstaller@1
displayName: Visual Studio Test Platform Installer

- 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
Expand All @@ -121,7 +53,7 @@ jobs:
- task: UseDotNet@2
displayName: Use .NET SDK
inputs:
version: 7.x
version: 8.x

- task: DotNetCoreCLI@2
displayName: dotnet restore
Expand Down Expand Up @@ -191,8 +123,8 @@ jobs:
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"
Copy-Item -Path "$(Build.SourcesDirectory)\Server\Dockerfile.pipelines" -Destination "$(build.artifactstagingdirectory)\Dockerfile"
Copy-Item -Path "$(Build.SourcesDirectory)\docker-compose\docker-compose.yml" -Destination "$(build.artifactstagingdirectory)\docker-compose.yml"
- task: PublishBuildArtifacts@1
displayName: Publish Artifact
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Desktop.Linux/bin/Debug/.net7.0/Remotely_Desktop.dll",
"program": "${workspaceFolder}/Desktop.Linux/bin/Debug/.net8.0/Remotely_Desktop.dll",
"args": [],
"cwd": "${workspaceFolder}/Desktop.Linux",
"console": "internalConsole",
Expand Down
1 change: 1 addition & 0 deletions Agent.Installer.Win/Agent.Installer.Win.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
Expand Down
5 changes: 3 additions & 2 deletions Agent.Installer.Win/Models/EmbeddedServerData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Runtime.Serialization;

namespace Remotely.Agent.Installer.Models;
Expand All @@ -23,5 +24,5 @@ public EmbeddedServerData(Uri serverUrl, string organizationId)
public string OrganizationId { get; set; } = string.Empty;

[DataMember]
public Uri ServerUrl { get; set; }
public Uri? ServerUrl { get; set; }
}
2 changes: 1 addition & 1 deletion Agent.Installer.Win/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 21 additions & 50 deletions Agent.Installer.Win/Services/EmbeddedServerDataReader.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
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<EmbeddedServerData> TryGetEmbeddedData(string filePath)
public async Task<EmbeddedServerData> TryGetEmbeddedData(string filePath)
{
try
{
Expand All @@ -25,60 +21,35 @@ public Task<EmbeddedServerData> TryGetEmbeddedData(string 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.");
}
using var fs = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
using var br = new BinaryReader(fs);
using var sr = new StreamReader(fs);

Logger.Write($"Found data signature at index {result}.");
fs.Seek(-4, SeekOrigin.End);
var dataSize = br.ReadInt32();
fs.Seek(-dataSize - 4, SeekOrigin.End);

fs.Seek(result + AppConstants.EmbeddedImmySignature.Length, SeekOrigin.Begin);
using (var reader = new BinaryReader(fs, Encoding.UTF8))
{
var serializedData = reader.ReadString();
if (dataSize == 0)
{
return EmbeddedServerData.Empty;
}

Logger.Write($"Extracted embedded data from EXE: {serializedData}");
var buffer = new byte[dataSize];
await fs.ReadAsync(buffer, 0, dataSize);
var json = Encoding.UTF8.GetString(buffer);

var embeddedData = _serializer.Deserialize<EmbeddedServerData>(serializedData);
if (embeddedData != null)
{
return Task.FromResult(embeddedData);
}
}
Logger.Write($"Extracted embedded data from EXE: {json}");

var embeddedData = _serializer.Deserialize<EmbeddedServerData>(json);
if (embeddedData is not null)
{
return embeddedData;
}
}
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;
return EmbeddedServerData.Empty;
}
}
2 changes: 1 addition & 1 deletion Agent.Installer.Win/Services/InstallerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void CreateSupportShortcut(string serverUrl, string deviceUuid, bool cre
var shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);
shortcut.Description = "Get IT support";
shortcut.IconLocation = Path.Combine(_installPath, "Remotely_Agent.exe");
shortcut.TargetPath = serverUrl.TrimEnd('/') + $"/GetSupport?deviceID={deviceUuid}";
shortcut.TargetPath = serverUrl.TrimEnd('/') + $"/get-support?deviceID={deviceUuid}";
shortcut.Save();

if (createSupportShortcut)
Expand Down
28 changes: 14 additions & 14 deletions Agent/Agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Copyright>Copyright © 2023 Immense Networks</Copyright>
Expand All @@ -24,19 +24,19 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="7.0.10" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.10" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.3.6" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.3.6" />
<PackageReference Include="Microsoft.WSMan.Runtime" Version="7.3.6" />
<PackageReference Include="System.Management.Automation" Version="7.3.6" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.2" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.4.1" />
<PackageReference Include="Microsoft.WSMan.Management" Version="7.4.1" />
<PackageReference Include="Microsoft.WSMan.Runtime" Version="7.4.1" />
<PackageReference Include="System.Management.Automation" Version="7.4.1" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Agent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private static void RegisterServices(IServiceCollection services)
services.AddSingleton<IAppLauncher, AppLauncherMac>();
services.AddSingleton<IUpdater, UpdaterMac>();
services.AddSingleton<IDeviceInformationService, DeviceInfoGeneratorMac>();
services.AddSingleton<IElevationDetector, ElevationDetectorMac>();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Agent/Services/FileLogsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async IAsyncEnumerable<byte[]> ReadAllBytes([EnumeratorCancellation] Canc
{
yield break;
}
yield return File.ReadAllBytes(file);
yield return chunk;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Agent/Services/MacOS/AppLauncherMac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ public class AppLauncherMac : IAppLauncher

public async Task<int> LaunchChatService(string pipeName, string userConnectionId, string requesterName, string orgName, string orgId, HubConnection hubConnection)
{
await hubConnection.SendAsync("DisplayMessage", "Feature under development.", "Feature is under development.", "bg-warning", userConnectionId);
await hubConnection.SendAsync("DisplayMessage", "Feature under development.", "Currently unsupported", "bg-warning", userConnectionId);
return 0;
}

public async Task LaunchRemoteControl(int targetSessionId, string sessionId, string accessKey, string userConnectionId, string requesterName, string orgName, string orgId, HubConnection hubConnection)
{
await hubConnection.SendAsync("DisplayMessage", "Feature under development.", "Feature is under development.", "bg-warning", userConnectionId);
await hubConnection.SendAsync("DisplayMessage", "Feature under development.", "Currently unsupported", "bg-warning", userConnectionId);
}

public async Task RestartScreenCaster(string[] viewerIds, string sessionId, string accessKey, string userConnectionId, string requesterName, string orgName, string orgId, HubConnection hubConnection, int targetSessionID = -1)
{
await hubConnection.SendAsync("DisplayMessage", "Feature under development.", "Feature is under development.", "bg-warning", userConnectionId);
await hubConnection.SendAsync("DisplayMessage", "Feature under development.", "Currently unsupported", "bg-warning", userConnectionId);
}
}
14 changes: 6 additions & 8 deletions Agent/Services/Windows/UpdaterWin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,23 @@ public async Task InstallLatestVersion()

var zipPath = Path.Combine(Path.GetTempPath(), "RemotelyUpdate.zip");

var installerPath = Path.Combine(Path.GetTempPath(), "Remotely_Installer.exe");
var installerPath = Path.Combine(Path.GetTempPath(), "Install-Remotely.ps1");
var platform = Environment.Is64BitOperatingSystem ? "x64" : "x86";

await _updateDownloader.DownloadFile(
$"{serverUrl}/Content/Remotely_Installer.exe",
$"{serverUrl}/Content/Install-Remotely.ps1",
installerPath);

await _updateDownloader.DownloadFile(
$"{serverUrl}/api/AgentUpdate/DownloadPackage/win-{platform}",
zipPath);

foreach (var proc in Process.GetProcessesByName("Remotely_Installer"))
{
proc.Kill();
}

_logger.LogInformation("Launching installer to perform update.");

Process.Start(installerPath, $"-install -quiet -path {zipPath} -serverurl {serverUrl} -organizationid {connectionInfo.OrganizationID}");
Process.Start(
"powershell.exe",
$"-ExecutionPolicy Bypass -File \"{installerPath}\" -Path \"{zipPath}\" " +
$"-OrganizationId {connectionInfo.OrganizationID} -ServerUrl {connectionInfo.Host}");
}
catch (WebException ex) when (ex.Status == WebExceptionStatus.Timeout)
{
Expand Down
2 changes: 1 addition & 1 deletion Desktop.Core/Desktop.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>.net7.0</TargetFramework>
<TargetFramework>.net8.0</TargetFramework>
<RootNamespace>Remotely.Desktop.Core</RootNamespace>
<AssemblyName>Remotely_Desktop.Core</AssemblyName>
<Platforms>AnyCPU;x64;x86</Platforms>
Expand Down
2 changes: 1 addition & 1 deletion Desktop.Linux/Desktop.Linux.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ApplicationIcon>Assets\favicon.ico</ApplicationIcon>
<AssemblyName>Remotely_Desktop</AssemblyName>
<RootNamespace>Remotely.Desktop.XPlat</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>x64</Platform>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PublishDir>..\Server\wwwroot\Content\Linux-x64\</PublishDir>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
Expand Down
Loading

0 comments on commit 646412b

Please sign in to comment.