diff --git a/.gitignore b/.gitignore index e238dcdb9..809ffc7a2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,7 @@ dist/ /output/ /config/ *.DotSettings + +# Downloaded build dependencies +tun2socks.exe +wintun.dll diff --git a/ci/package-agent-windows.ps1 b/ci/package-agent-windows.ps1 index 2d56aab55..8931f3dd5 100644 --- a/ci/package-agent-windows.ps1 +++ b/ci/package-agent-windows.ps1 @@ -8,6 +8,9 @@ param( [string] $PedmMsix, [parameter(Mandatory = $true)] [string] $SessionExe, + [parameter(Mandatory = $true)] + [ValidateSet('x64', 'arm64')] + [string] $Architecture, [string] $Outfile ) @@ -89,6 +92,10 @@ function New-AgentMsi() { [parameter(Mandatory = $true)] # The path to the devolutions-session.exe file. [string] $SessionExe, + [parameter(Mandatory = $true)] + [ValidateSet('x64', 'arm64')] + # Architecture: x64 or arm64 + [string] $Architecture, # Only required if `Generate` is not set. [string] $Outfile ) @@ -139,8 +146,9 @@ function New-AgentMsi() { Push-Location Set-Location "$repoDir\package\AgentWindowsManaged" - # Set the MSI version, which is read by `package/WindowsManaged/Program.cs`. + # Set the MSI version and platform, which are read by `package/AgentWindowsManaged/Program.cs`. $Env:DAGENT_VERSION = $version.Substring(2) + $Env:DAGENT_PLATFORM = $Architecture if ($Generate) { # This is used by `package/WindowsManaged/Program.cs`. $Env:DAGENT_MSI_SOURCE_ONLY_BUILD = '1' @@ -167,4 +175,4 @@ function New-AgentMsi() { Pop-Location } -New-AgentMsi -Generate:($Generate.IsPresent) -Exe $Exe -PedmDll $PedmDll -PedmMsix $PedmMsix -SessionExe $SessionExe -Outfile $Outfile +New-AgentMsi -Generate:($Generate.IsPresent) -Exe $Exe -PedmDll $PedmDll -PedmMsix $PedmMsix -SessionExe $SessionExe -Architecture $Architecture -Outfile $Outfile diff --git a/ci/tlk.ps1 b/ci/tlk.ps1 index 36cee104c..7f6077886 100755 --- a/ci/tlk.ps1 +++ b/ci/tlk.ps1 @@ -577,6 +577,7 @@ class TlkRecipe $ShortVersion = $this.Version.Substring(2) # msi version $Env:DAGENT_VERSION="$ShortVersion" + $Env:DAGENT_PLATFORM=$this.Target.Architecture Push-Location Set-Location "$($this.SourcePath)/package/Agent$($this.Target.Platform)Managed" diff --git a/package/AgentWindowsManaged/DevolutionsAgent.csproj b/package/AgentWindowsManaged/DevolutionsAgent.csproj index 42ec48a13..527dd4bd4 100644 --- a/package/AgentWindowsManaged/DevolutionsAgent.csproj +++ b/package/AgentWindowsManaged/DevolutionsAgent.csproj @@ -25,7 +25,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/package/AgentWindowsManaged/Dialogs/FeaturesDialog.cs b/package/AgentWindowsManaged/Dialogs/FeaturesDialog.cs index d11f1ecd8..3225cd69d 100644 --- a/package/AgentWindowsManaged/Dialogs/FeaturesDialog.cs +++ b/package/AgentWindowsManaged/Dialogs/FeaturesDialog.cs @@ -48,7 +48,7 @@ private ListViewItem CreateFeatureListItem(FeatureItem featureItem, bool addLoca Tag = featureItem }; - featureItem.View = view; + featureItem.ViewModel = view; if (addLocal) { @@ -94,18 +94,18 @@ private void BuildFeaturesHierarchy() continue; } - featureItem.View = CreateFeatureListItem(featureItem, addLocal.Contains(featureItem.Name), remove.Contains(featureItem.Name)); + featureItem.ViewModel = CreateFeatureListItem(featureItem, addLocal.Contains(featureItem.Name), remove.Contains(featureItem.Name)); featureItems.Add(featureItem); foreach (FeatureItem childFeature in this.features.Where(x => x.ParentName == featureItem.Name)) { - childFeature.View = CreateFeatureListItem(childFeature, addLocal.Contains(childFeature.Name), remove.Contains(childFeature.Name), level: 1); + childFeature.ViewModel = CreateFeatureListItem(childFeature, addLocal.Contains(childFeature.Name), remove.Contains(childFeature.Name), level: 1); featureItems.Add(childFeature); } } featureItems.Where(x => x.Display != FeatureDisplay.hidden) - .Select(x => x.View) + .Select(x => x.ViewModel) .Cast() .ForEach(featuresTree.Items.Add); @@ -165,6 +165,6 @@ private void FeaturesTree_SelectedIndexChanged(object sender, EventArgs e) private static bool IsViewChecked(FeatureItem feature) { - return feature.View is ListViewItem {Checked: true}; + return feature.ViewModel is ListViewItem {Checked: true}; } } diff --git a/package/AgentWindowsManaged/Program.cs b/package/AgentWindowsManaged/Program.cs index 2ec247afe..bfb457806 100644 --- a/package/AgentWindowsManaged/Program.cs +++ b/package/AgentWindowsManaged/Program.cs @@ -75,26 +75,24 @@ private static string ResolveArtifact(string varName, string defaultPath = null) return path; } - private static string DevolutionsAgentExePath => ResolveArtifact("DAGENT_EXECUTABLE", "..\\..\\target\\x86_64-pc-windows-msvc\\release\\devolutions-agent.exe"); + private static string DevolutionsAgentExePath => ResolveArtifact("DAGENT_EXECUTABLE", "..\\..\\target\\debug\\devolutions-agent.exe"); private static string DevolutionsDesktopAgentPath { // ReSharper disable once ArrangeAccessorOwnerBody - get => ResolveDirectory("DAGENT_DESKTOP_AGENT_PATH", "..\\..\\dotnet\\DesktopAgent\\bin\\Release\\"); + get => ResolveDirectory("DAGENT_DESKTOP_AGENT_PATH", "..\\..\\dotnet\\DesktopAgent\\bin\\Debug\\"); } - private static string DevolutionsPedmShellExtDll => ResolveArtifact("DAGENT_PEDM_SHELL_EXT_DLL", "..\\..\\target\\x86_64-pc-windows-msvc\\release\\devolutions_pedm_shell_ext.dll"); + private static string DevolutionsPedmShellExtDll => ResolveArtifact("DAGENT_PEDM_SHELL_EXT_DLL", "..\\..\\target\\debug\\devolutions_pedm_shell_ext.dll"); - private static string DevolutionsPedmShellExtMsix => ResolveArtifact("DAGENT_PEDM_SHELL_EXT_MSIX", "..\\..\\target\\x86_64-pc-windows-msvc\\release\\DevolutionsPedmShellExt.msix"); + private static string DevolutionsPedmShellExtMsix => ResolveArtifact("DAGENT_PEDM_SHELL_EXT_MSIX", "..\\..\\target\\debug\\DevolutionsPedmShellExt.msix"); - private static string DevolutionsSession => ResolveArtifact("DAGENT_SESSION_EXECUTABLE", "..\\..\\target\\x86_64-pc-windows-msvc\\release\\devolutions-session.exe"); + private static string DevolutionsSession => ResolveArtifact("DAGENT_SESSION_EXECUTABLE", "..\\..\\target\\debug\\devolutions-session.exe"); private static string DevolutionsTun2SocksExe => ResolveArtifact("DAGENT_TUN2SOCKS_EXE", "..\\..\\tun2socks.exe"); private static string DevolutionsWintunDll => ResolveArtifact("DAGENT_WINTUN_DLL", "..\\..\\wintun.dll"); - private static string TargetOutputPath => ResolveDirectory("TARGET_OUTPUT_PATH", "..\\..\\target\\x86_64-pc-windows-msvc\\release\\"); - private static Version DevolutionsAgentVersion { get @@ -121,6 +119,34 @@ private static Version DevolutionsAgentVersion } } + private static WixSharp.Platform TargetPlatform + { + get + { + string platform = Environment.GetEnvironmentVariable("DAGENT_PLATFORM"); + +#if DEBUG + if (string.IsNullOrWhiteSpace(platform)) + { + return WixSharp.Platform.x64; + } +#endif + + if (string.IsNullOrEmpty(platform)) + { + throw new Exception("The environment variable DAGENT_PLATFORM is not specified or is invalid"); + } + + // Normalize architecture string to handle various formats from CI/build systems + return platform.ToLowerInvariant() switch + { + "x64" or "x86_64" or "amd64" => WixSharp.Platform.x64, + "arm64" or "aarch64" => WixSharp.Platform.arm64, + _ => throw new Exception($"unrecognized platform: {platform}. Supported values: x64, x86_64, amd64, arm64, aarch64") + }; + } + } + private static bool SourceOnlyBuild => !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("DAGENT_MSI_SOURCE_ONLY_BUILD")); private static string ProjectLangId @@ -164,7 +190,7 @@ static void Main() InstallerVersion = 500, // Windows Installer 5.0; Server 2008 R2 / Windows 7 InstallScope = InstallScope.perMachine, InstallPrivileges = InstallPrivileges.elevated, - Platform = Platform.x64, + Platform = TargetPlatform, #if DEBUG PreserveTempFiles = true, OutDir = "Debug", diff --git a/package/AgentWindowsManaged/Resources/Features.cs b/package/AgentWindowsManaged/Resources/Features.cs index 4a7453bfc..f6f1f98ef 100644 --- a/package/AgentWindowsManaged/Resources/Features.cs +++ b/package/AgentWindowsManaged/Resources/Features.cs @@ -12,24 +12,24 @@ internal static class Features internal static IEnumerable ExperimentalFeatures => [ ]; - internal static Feature AGENT_UPDATER_FEATURE = new("!(loc.FeatureAgentUpdaterName)", "!(loc.FeatureAgentUpdaterDescription)", true, true) + internal static Feature AGENT_UPDATER_FEATURE = new("!(loc.FeatureAgentUpdaterName)", "!(loc.FeatureAgentUpdaterDescription)", isEnabled: true, allowChange: true) { Id = $"{FEATURE_ID_PREFIX}Updater" }; - internal static Feature AGENT_FEATURE = new("!(loc.FeatureAgentName)", true, false) + internal static Feature AGENT_FEATURE = new("!(loc.FeatureAgentName)", isEnabled: true, allowChange: false) { Id = $"{FEATURE_ID_PREFIX}Agent", Description = "!(loc.FeatureAgentDescription)", Children = [ AGENT_UPDATER_FEATURE ] }; - internal static Feature PEDM_FEATURE = new("!(loc.FeaturePedmName)", "!(loc.FeaturePedmDescription)", false) + internal static Feature PEDM_FEATURE = new("!(loc.FeaturePedmName)", "!(loc.FeaturePedmDescription)", isEnabled: false) { Id = $"{FEATURE_ID_PREFIX}Pedm" }; - internal static Feature SESSION_FEATURE = new("!(loc.FeatureSessionName)", "!(loc.FeatureSessionDescription)", true) + internal static Feature SESSION_FEATURE = new("!(loc.FeatureSessionName)", "!(loc.FeatureSessionDescription)", isEnabled: true) { Id = $"{FEATURE_ID_PREFIX}Session" };