Skip to content

Commit

Permalink
Merge pull request #53 from svrooij/feature/auto-update
Browse files Browse the repository at this point in the history
Turn on Auto update?
  • Loading branch information
svrooij authored Apr 24, 2024
2 parents 5223c56 + ebd9d87 commit d2bce51
Show file tree
Hide file tree
Showing 18 changed files with 307 additions and 220 deletions.
12 changes: 11 additions & 1 deletion src/Svrooij.WinTuner.CmdLets/Commands/DeployWtWin32App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,19 @@ await batch.AddBatchRequestStepAsync(graphServiceClient.DeviceAppManagement.Mobi
// Copy assignments from old app to new app
if (oldWin32App.Assignments is not null && oldWin32App.Assignments.Count > 0)
{
// This part is to enable auto update for the new app, if that was not set on the old app
var assignments = oldWin32App.Assignments;
foreach (var assignment in assignments)
{
if (assignment.Intent == GraphModels.InstallIntent.Available && assignment.Settings is null)
{
assignment.Settings = new GraphModels.Win32LobAppAssignmentSettings { AutoUpdateSettings = new GraphModels.Win32LobAppAutoUpdateSettings { AutoUpdateSupersededApps = GraphModels.Win32LobAppAutoUpdateSupersededApps.Enabled } };
}
}

await batch.AddBatchRequestStepAsync(graphServiceClient.DeviceAppManagement.MobileApps[newAppId].Assign.ToPostRequestInformation(new Microsoft.Graph.Beta.DeviceAppManagement.MobileApps.Item.Assign.AssignPostRequestBody
{
MobileAppAssignments = oldWin32App.Assignments
MobileAppAssignments = assignments, //oldWin32App.Assignments
}));

// Remove assignments from old app
Expand Down
11 changes: 9 additions & 2 deletions src/Svrooij.WinTuner.CmdLets/Commands/Update-WtIntuneApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Svrooij.WinTuner.CmdLets.Commands;
/// </summary>
/// <example>
/// <para type="description">Update the categories of an app and make it available for all users</para>
/// <code>Update-WtIntuneApp -AppId "1450c17d-aee5-4bef-acf9-9e0107d340f2" -UseDefaultCredentials -Categories "Productivity","Business" -AvailableFor "AllUsers"</code>
/// <code>Update-WtIntuneApp -AppId "1450c17d-aee5-4bef-acf9-9e0107d340f2" -UseDefaultCredentials -Categories "Productivity","Business" -AvailableFor "AllUsers" -EnableAutoUpdate $true</code>
/// </example>
[Cmdlet(VerbsData.Update, "WtIntuneApp")]
[OutputType(typeof(MobileApp))]
Expand Down Expand Up @@ -58,6 +58,13 @@ public class UpdateWtIntuneApp : BaseIntuneCmdlet
HelpMessage = "Groups that the app should be uninstalled for, Group Object ID or 'AllUsers'/'AllDevices'")]
public string[]? UninstallFor { get; set; }

/// <summary>
/// <para type="description">Enable auto update for the app</para>
/// </summary>
[Parameter(Mandatory = false,
HelpMessage = "Enable auto update for the app")]
public bool EnableAutoUpdate { get; set; } = false;

[ServiceDependency]
private ILogger<UpdateWtIntuneApp>? logger;

Expand All @@ -83,7 +90,7 @@ public override async Task ProcessRecordAsync(CancellationToken cancellationToke
(UninstallFor is not null && UninstallFor.Any()))
{
logger?.LogInformation("Assigning app {appId} to groups", AppId);
await graphServiceClient.AssignAppAsync(AppId!, RequiredFor, AvailableFor, UninstallFor, cancellationToken);
await graphServiceClient.AssignAppAsync(AppId!, RequiredFor, AvailableFor, UninstallFor, EnableAutoUpdate, cancellationToken);
}

// Load the app to get the relationships
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Azure.Identity" Version="1.11.2" />
<PackageReference Include="Svrooij.PowerShell.DependencyInjection" Version="1.1.0" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1">
<PrivateAssets>All</PrivateAssets>
Expand Down
24 changes: 24 additions & 0 deletions src/Svrooij.WinTuner.CmdLets/Svrooij.WinTuner.CmdLets.dll-Help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,18 @@
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>EnableAutoUpdate</maml:name>
<maml:description>
<maml:para>Enable auto update for the app</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Boolean</command:parameterValue>
<dev:type>
<maml:name>Boolean</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
Expand Down Expand Up @@ -2120,6 +2132,18 @@
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
<maml:name>EnableAutoUpdate</maml:name>
<maml:description>
<maml:para>Enable auto update for the app</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Boolean</command:parameterValue>
<dev:type>
<maml:name>Boolean</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
Expand Down
2 changes: 1 addition & 1 deletion src/Svrooij.WinTuner.CmdLets/WinTuner.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"New-WtWingetPackage",
"Remove-WtWin32App",
"Unprotect-IntuneWinPackage"
"Update-WtWin32App"
"Update-WtIntuneApp"
)

# Variables to export from this module.
Expand Down
22 changes: 19 additions & 3 deletions src/Svrooij.WinTuner.CmdLets/docs/Update-WtIntuneApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Update an app in Intune

```
Update-WtIntuneApp -AppId <String> [-Categories <String[]>] [-AvailableFor <String[]>]
[-RequiredFor <String[]>] [-UninstallFor <String[]>] [[-UseManagedIdentity] <Boolean>]
[[-UseDefaultAzureCredential] <Boolean>] [[-Token] <String>] [[-Username] <String>] [[-TenantId] <String>]
[[-ClientId] <String>] [[-ClientSecret] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]
[-RequiredFor <String[]>] [-UninstallFor <String[]>] [-EnableAutoUpdate <Boolean>]
[[-UseManagedIdentity] <Boolean>] [[-UseDefaultAzureCredential] <Boolean>] [[-Token] <String>]
[[-Username] <String>] [[-TenantId] <String>] [[-ClientId] <String>] [[-ClientSecret] <String>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -231,6 +232,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -EnableAutoUpdate
Enable auto update for the app
```yaml
Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
84 changes: 47 additions & 37 deletions src/Svrooij.WinTuner.CmdLets/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"net8.0": {
"Azure.Identity": {
"type": "Direct",
"requested": "[1.10.4, )",
"resolved": "1.10.4",
"contentHash": "hSvisZy9sld0Gik1X94od3+rRXCx+AKgi+iLH6fFdlnRZRePn7RtrqUGSsORiH2h8H2sc4NLTrnuUte1WL+QuQ==",
"requested": "[1.11.2, )",
"resolved": "1.11.2",
"contentHash": "mihECA1msfwdjTPXHwK9N3n4ln8jMB0DuT0r2caDGPriRT1vca4/Jgmo6FmFZPo8RQsQt1fVn1Gxv5WqkyHVeA==",
"dependencies": {
"Azure.Core": "1.36.0",
"Microsoft.Identity.Client": "4.56.0",
"Microsoft.Identity.Client.Extensions.Msal": "4.56.0",
"Azure.Core": "1.38.0",
"Microsoft.Identity.Client": "4.60.3",
"Microsoft.Identity.Client.Extensions.Msal": "4.60.3",
"System.Memory": "4.5.4",
"System.Security.Cryptography.ProtectedData": "4.7.0",
"System.Text.Json": "4.7.2",
Expand All @@ -37,10 +37,11 @@
},
"Azure.Core": {
"type": "Transitive",
"resolved": "1.36.0",
"contentHash": "vwqFZdHS4dzPlI7FFRkPx9ctA+aGGeRev3gnzG8lntWvKMmBhAmulABi1O9CEvS3/jzYt7yA+0pqVdxkpAd7dQ==",
"resolved": "1.38.0",
"contentHash": "IuEgCoVA0ef7E4pQtpC3+TkPbzaoQfa77HlfJDmfuaJUCVJmn7fT0izamZiryW5sYUFKizsftIxMkXKbgIcPMQ==",
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "1.1.1",
"System.ClientModel": "1.0.0",
"System.Diagnostics.DiagnosticSource": "6.0.1",
"System.Memory.Data": "1.0.2",
"System.Numerics.Vectors": "4.5.0",
Expand Down Expand Up @@ -289,28 +290,28 @@
},
"Microsoft.Identity.Client": {
"type": "Transitive",
"resolved": "4.60.1",
"contentHash": "rC+qiskr8RKq2a43hH55vuDRz4Wto+bxwxMrKzCIOann1NL0OFFTjEk4ZVnTTBdijVWC6mhOaSmdV1H6J6bXmA==",
"resolved": "4.60.3",
"contentHash": "jve1RzmSpBhGlqMzPva6VfRbLMLZZc1Q8WRVZf8+iEruQkBgDTJPq8OeTehcY4GGYG1j6UB1xVofVE+n4BLDdw==",
"dependencies": {
"Microsoft.IdentityModel.Abstractions": "6.35.0",
"System.Diagnostics.DiagnosticSource": "6.0.1"
}
},
"Microsoft.Identity.Client.Broker": {
"type": "Transitive",
"resolved": "4.60.1",
"contentHash": "q5W6Sl853jiuFVrcr4c0cWFFy/Szmm6GMVpL8QEt5GEymJbDTwhNvNC6qWP3yoy+xBZL1KYExt5MVj3QZ+pFjA==",
"resolved": "4.60.3",
"contentHash": "ki+l9Jxp5ift/c5iHS6LC0Y+MEZ7cPzC91l1Aj4tgzV6VzvF7/qO4vclFWQsB4MiA0KUMybkSOAZEuRahrHGlQ==",
"dependencies": {
"Microsoft.Identity.Client": "4.60.1",
"Microsoft.Identity.Client": "4.60.3",
"Microsoft.Identity.Client.NativeInterop": "0.16.0"
}
},
"Microsoft.Identity.Client.Extensions.Msal": {
"type": "Transitive",
"resolved": "4.60.1",
"contentHash": "EdPcGqvruFzNBcW+/3DSP4vNmLNYXSSnngj+QecAxmy6VRnvA7kt5KE2bU8qQmt4KkOitNHBVYVwze2XkqOLxw==",
"resolved": "4.60.3",
"contentHash": "X1Cz14/RbmlLshusE5u2zfG+5ul6ttgou19BZe5Mdw1qm6fgOI9/imBB2TIsx2UD7nkgd2+MCSzhbukZf7udeg==",
"dependencies": {
"Microsoft.Identity.Client": "4.60.1",
"Microsoft.Identity.Client": "4.60.3",
"System.Security.Cryptography.ProtectedData": "4.5.0"
}
},
Expand All @@ -321,23 +322,23 @@
},
"Microsoft.IdentityModel.Abstractions": {
"type": "Transitive",
"resolved": "7.5.0",
"contentHash": "seOFPaBQh2K683eFujAuDsrO2XbOA+SvxRli+wu7kl+ZymuGQzjmmUKfyFHmDazpPOBnmOX1ZnjX7zFDZHyNIA=="
"resolved": "7.5.1",
"contentHash": "PT16ZFbPIiMsYv07oy3zOjqUOJ7xutGBkJTOX0+IbNyU6+O6X7aIxjq9EaSSRLWbekRgamgtmfg8Xjw6A6Ua9g=="
},
"Microsoft.IdentityModel.JsonWebTokens": {
"type": "Transitive",
"resolved": "7.5.0",
"contentHash": "mfyiGptbcH+oYrzAtWWwuV+7MoM0G0si+9owaj6DGWInhq/N/KDj/pWHhq1ShdmBu332gjP+cppjgwBpsOj7Fg==",
"resolved": "7.5.1",
"contentHash": "93CGSa8RPdZU8zfvA3nf9NGKUqEnQrE12VzYlMqKh72ddhzusosqLNEUgH/YhFWBLRFOnY1RCgHMV7pR+sAx2w==",
"dependencies": {
"Microsoft.IdentityModel.Tokens": "7.5.0"
"Microsoft.IdentityModel.Tokens": "7.5.1"
}
},
"Microsoft.IdentityModel.Logging": {
"type": "Transitive",
"resolved": "7.5.0",
"contentHash": "3BInZEajJvnTDP/YRrmJ3Fyw8XAWWR9jG+3FkhhzRJJYItVL+BEH9qlgxSmtrxp7S7N6TOv+Y+X8BG61viiehQ==",
"resolved": "7.5.1",
"contentHash": "PnpAQX20BAiDIPYmWUyQSlEaWD8BLXzHpiDGTCT568Cs0ReOeyzNe401LzCeiv6ilug/KefVeV1CeqtCHTo8dw==",
"dependencies": {
"Microsoft.IdentityModel.Abstractions": "7.5.0"
"Microsoft.IdentityModel.Abstractions": "7.5.1"
}
},
"Microsoft.IdentityModel.Protocols": {
Expand All @@ -360,10 +361,10 @@
},
"Microsoft.IdentityModel.Tokens": {
"type": "Transitive",
"resolved": "7.5.0",
"contentHash": "owe33wqe0ZbwBxM3D90I0XotxNyTdl85jud03d+OrUOJNnTiqnYePwBk3WU9yW0Rk5CYX+sfSim7frmu6jeEzQ==",
"resolved": "7.5.1",
"contentHash": "Q3DKpyFViP84IUlTFKH/zIkswIrmSh2Vd/eFDo4wlOHy4DYxoweZEEw4kDEiKt9VCX6o7SddK3HK2xDYyFpexA==",
"dependencies": {
"Microsoft.IdentityModel.Logging": "7.5.0"
"Microsoft.IdentityModel.Logging": "7.5.1"
}
},
"Microsoft.Kiota.Abstractions": {
Expand Down Expand Up @@ -659,8 +660,8 @@
},
"Riok.Mapperly": {
"type": "Transitive",
"resolved": "3.4.0",
"contentHash": "bTxBEQ0+2x816IL78Fv0B/KkaGRtzfisit9dfWTfa7jjjwMMzpMW9A+V/hyxqHdJtYvtDL6dUNMLJige4zxJvw=="
"resolved": "3.5.1",
"contentHash": "ECFSdemqIN7HoCu8lOtGYW15fYK5XgSg9tpaspdevi4rj6Z4KomMQz6bKID1L5WMHxjyexix250wP5eAF0iKNw=="
},
"runtime.linux-arm.runtime.native.System.IO.Ports": {
"type": "Transitive",
Expand Down Expand Up @@ -739,6 +740,15 @@
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"System.ClientModel": {
"type": "Transitive",
"resolved": "1.0.0",
"contentHash": "I3CVkvxeqFYjIVEP59DnjbeoGNfo/+SZrCLpRz2v/g0gpCHaEMPtWSY0s9k/7jR1rAsLNg2z2u1JRB76tPjnIw==",
"dependencies": {
"System.Memory.Data": "1.0.2",
"System.Text.Json": "4.7.2"
}
},
"System.CodeDom": {
"type": "Transitive",
"resolved": "8.0.0",
Expand Down Expand Up @@ -872,11 +882,11 @@
},
"System.IdentityModel.Tokens.Jwt": {
"type": "Transitive",
"resolved": "7.5.0",
"contentHash": "D0TtrWOfoPdyYSlvOGaU9F1QR+qrbgJ/4eiEsQkIz7YQKIKkGXQldXukn6cYG9OahSq5UVMvyAIObECpH6Wglg==",
"resolved": "7.5.1",
"contentHash": "UUw+E0R73lZLlXgneYIJQxNs1kfbcxjVzw64JQyiwjqCd4HMpAbjn+xRo86QZT84uHq8/MkqvfH82tgjgPzpuw==",
"dependencies": {
"Microsoft.IdentityModel.JsonWebTokens": "7.5.0",
"Microsoft.IdentityModel.Tokens": "7.5.0"
"Microsoft.IdentityModel.JsonWebTokens": "7.5.1",
"Microsoft.IdentityModel.Tokens": "7.5.1"
}
},
"System.IO": {
Expand Down Expand Up @@ -1258,11 +1268,11 @@
"Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )",
"Microsoft.Extensions.Options": "[8.0.2, )",
"Microsoft.Graph.Beta": "[5.59.0-preview, )",
"Microsoft.Identity.Client.Broker": "[4.60.1, )",
"Microsoft.Identity.Client.Extensions.Msal": "[4.60.1, )",
"Riok.Mapperly": "[3.4.0, )",
"Microsoft.Identity.Client.Broker": "[4.60.3, )",
"Microsoft.Identity.Client.Extensions.Msal": "[4.60.3, )",
"Riok.Mapperly": "[3.5.1, )",
"SvRooij.ContentPrep": "[0.1.3-alpha0001, )",
"System.IdentityModel.Tokens.Jwt": "[7.5.0, )",
"System.IdentityModel.Tokens.Jwt": "[7.5.1, )",
"Winget.CommunityRepository": "[1.0.0, )"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="8.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<ProjectReference Include="..\Winget.CommunityRepository\Winget.CommunityRepository.csproj" />
</ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion src/WingetIntune.Cli/Commands/PublishCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public PublishCommand() : base(name, description)
AddOption(RequiredForOption);
AddOption(UninstallForOption);
AddOption(new Option<bool>("--auto-package", "Automatically package the app if it's not found in the package folder") { IsHidden = true });
AddOption(new Option<bool>("--auto-update", "Turn on auto update, if assigned as available") { IsHidden = true });
AddOption(PackageCommand.GetArchitectureOption(isHidden: true));
AddOption(PackageCommand.GetInstallerContextOption(isHidden: true));
this.Handler = CommandHandler.Create(HandleCommand);
Expand Down Expand Up @@ -99,7 +100,8 @@ await intuneManager.GenerateInstallerPackage(options.TempFolder,
Categories = options.Category,
AvailableFor = options.Available,
RequiredFor = options.Required,
UninstallFor = options.Uninstall
UninstallFor = options.Uninstall,
AddAutoUpdateSetting = options.AutoUpdate
};

var app = packageInfo.Source == PackageSource.Store
Expand All @@ -124,6 +126,7 @@ internal class PublishCommandOptions : WinGetRootCommand.DefaultOptions
public string[] Uninstall { get; set; } = Array.Empty<string>();

public bool AutoPackage { get; set; }
public bool AutoUpdate { get; set; }
public string TempFolder { get; set; }
public InstallerContext InstallerContext { get; set; }
public Architecture Architecture { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/WingetIntune.Cli/WingetIntune.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Azure.Identity" Version="1.11.2" />
<PackageReference Include="ConsoleTables" Version="2.6.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
Expand Down
Loading

0 comments on commit d2bce51

Please sign in to comment.