From d281c711a20966c6d4d110de3e0b9cd29f40b624 Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:33:07 +0200 Subject: [PATCH] Fixed auto update when superseeding (#90) Fixed #84 --- .../Commands/DeployWtWin32App.cs | 3 ++- src/WingetIntune/Graph/GraphWorkflows.cs | 3 ++- .../Graph/Win32LobAppAutoUpdateSettings.cs | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/WingetIntune/Graph/Win32LobAppAutoUpdateSettings.cs diff --git a/src/Svrooij.WinTuner.CmdLets/Commands/DeployWtWin32App.cs b/src/Svrooij.WinTuner.CmdLets/Commands/DeployWtWin32App.cs index 4e6bcce..3082b46 100644 --- a/src/Svrooij.WinTuner.CmdLets/Commands/DeployWtWin32App.cs +++ b/src/Svrooij.WinTuner.CmdLets/Commands/DeployWtWin32App.cs @@ -245,7 +245,8 @@ await batch.AddBatchRequestStepAsync(graphServiceClient.DeviceAppManagement.Mobi { if (assignment.Intent == GraphModels.InstallIntent.Available && assignment.Settings is null) { - //assignment.Settings = new GraphModels.Win32LobAppAssignmentSettings { AutoUpdateSettings = new GraphModels.Win32LobAppAutoUpdateSettings { AutoUpdateSupersededApps = GraphModels.Win32LobAppAutoUpdateSupersededApps.Enabled } }; + assignment.Settings = new GraphModels.Win32LobAppAssignmentSettings { Notifications = GraphModels.Win32LobAppNotification.ShowReboot }; + assignment.Settings.AdditionalData.Add("autoUpdateSettings", new Win32LobAppAutoUpdateSettings()); } } diff --git a/src/WingetIntune/Graph/GraphWorkflows.cs b/src/WingetIntune/Graph/GraphWorkflows.cs index 4a9ad6d..c97d025 100644 --- a/src/WingetIntune/Graph/GraphWorkflows.cs +++ b/src/WingetIntune/Graph/GraphWorkflows.cs @@ -70,7 +70,8 @@ private static List GenerateAssignments(string[] groups, In MobileAppAssignmentSettings? settings = null; if (intent == InstallIntent.Available && addSetting) { - //settings = new Win32LobAppAssignmentSettings { AutoUpdateSettings = new Win32LobAppAutoUpdateSettings { AutoUpdateSupersededApps = Win32LobAppAutoUpdateSupersededApps.Enabled } }; + settings = new Win32LobAppAssignmentSettings { Notifications = Win32LobAppNotification.ShowReboot }; + settings.AdditionalData.Add("autoUpdateSettings", new Win32LobAppAutoUpdateSettings()); } if (groups is not null && groups.Any()) { diff --git a/src/WingetIntune/Graph/Win32LobAppAutoUpdateSettings.cs b/src/WingetIntune/Graph/Win32LobAppAutoUpdateSettings.cs new file mode 100644 index 0000000..585e1a9 --- /dev/null +++ b/src/WingetIntune/Graph/Win32LobAppAutoUpdateSettings.cs @@ -0,0 +1,17 @@ +using Microsoft.Graph.Beta.Models; + +namespace WingetIntune.Graph; +public class Win32LobAppAutoUpdateSettings : Entity +{ + public Win32LobAppAutoUpdateSettings() + { + base.OdataType = "microsoft.graph.win32LobAppAutoUpdateSettings"; + AutoUpdateSupersededAppsState = "enabled"; + } + + public string? AutoUpdateSupersededAppsState + { + get => BackingStore?.Get("autoUpdateSupersededAppsState"); + set => BackingStore?.Set("autoUpdateSupersededAppsState", value); + } +}