Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ dist/
/output/
/config/
*.DotSettings

# Downloaded build dependencies
tun2socks.exe
wintun.dll
12 changes: 10 additions & 2 deletions ci/package-agent-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ param(
[string] $PedmMsix,
[parameter(Mandatory = $true)]
[string] $SessionExe,
[parameter(Mandatory = $true)]
[ValidateSet('x64', 'arm64')]
[string] $Architecture,
[string] $Outfile
)

Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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'
Expand All @@ -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
1 change: 1 addition & 0 deletions ci/tlk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions package/AgentWindowsManaged/DevolutionsAgent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<EmbeddedResource Include="Resources\DevolutionsAgent_fr-fr.wxl" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.6.1" />
<PackageReference Include="WixSharp" Version="1.26.0" />
Expand All @@ -39,7 +39,7 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.26100.4948" />
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.26100.7705" />
</ItemGroup>
<ItemGroup>
<Compile Update="Dialogs\VerifyReadyDialog.cs" />
Expand Down
10 changes: 5 additions & 5 deletions package/AgentWindowsManaged/Dialogs/FeaturesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private ListViewItem CreateFeatureListItem(FeatureItem featureItem, bool addLoca
Tag = featureItem
};

featureItem.View = view;
featureItem.ViewModel = view;

if (addLocal)
{
Expand Down Expand Up @@ -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<ListViewItem>()
.ForEach(featuresTree.Items.Add);

Expand Down Expand Up @@ -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};
}
}
42 changes: 34 additions & 8 deletions package/AgentWindowsManaged/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions package/AgentWindowsManaged/Resources/Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ internal static class Features

internal static IEnumerable<Feature> 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"
};
Expand Down
Loading