From 926780b36bf1a0b51f6bf57d1758d3aa21f0fc2b Mon Sep 17 00:00:00 2001 From: Stephan van Rooij <1292510+svrooij@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:48:17 +0100 Subject: [PATCH] Package update and allow setting prefered installer Fixed #144 --- .../Commands/ConnectWtWinTuner.cs | 3 +- .../Commands/GetWtToken.cs | 3 +- .../Commands/NewWtWingetPackage.cs | 14 +- src/Svrooij.WinTuner.CmdLets/README.md | 10 ++ .../Svrooij.WinTuner.CmdLets.dll-Help.xml | 50 ++++++ .../packages.lock.json | 63 ++++---- .../WinTuner.Proxy.Client.csproj | 2 +- .../Winget.CommunityRepository.Ef.csproj | 4 +- .../Winget.CommunityRepository.csproj | 2 +- src/WingetIntune.Cli/WingetIntune.Cli.csproj | 2 +- src/WingetIntune.Cli/packages.lock.json | 119 +++++++------- .../ComputeBestInstallerForPackageCommand.cs | 142 +++++++++++++++++ src/WingetIntune/Graph/GraphAppUploader.cs | 3 +- src/WingetIntune/Intune/IntuneManager.cs | 132 +--------------- src/WingetIntune/Models/PackageInfo.cs | 18 +-- src/WingetIntune/Models/PackageOptions.cs | 1 + src/WingetIntune/WingetIntune.csproj | 6 +- .../WingetServiceCollectionExtension.cs | 1 + src/WingetIntune/packages.lock.json | 148 +++++++++--------- .../Intune/IntuneManagerTests.cs | 9 +- tests/WingetIntune.Tests/packages.lock.json | 85 +++++----- 21 files changed, 454 insertions(+), 363 deletions(-) create mode 100644 src/WingetIntune/Commands/ComputeBestInstallerForPackageCommand.cs diff --git a/src/Svrooij.WinTuner.CmdLets/Commands/ConnectWtWinTuner.cs b/src/Svrooij.WinTuner.CmdLets/Commands/ConnectWtWinTuner.cs index 5a2a356..d751604 100644 --- a/src/Svrooij.WinTuner.CmdLets/Commands/ConnectWtWinTuner.cs +++ b/src/Svrooij.WinTuner.CmdLets/Commands/ConnectWtWinTuner.cs @@ -267,9 +267,10 @@ public override async Task ProcessRecordAsync(CancellationToken cancellationToke _logger?.LogInformation("Connecting to Intune using {ParameterSetName}", ParameterSetName); AuthenticationProvider = CreateAuthenticationProvider(cancellationToken); + // Try getting a token at this point helps solve a lot of issues. + var token = await GetTokenAsync(cancellationToken); if (Test) { - var token = await GetTokenAsync(cancellationToken); _logger?.LogInformation("Got token {Token}", token); WriteObject(token); } diff --git a/src/Svrooij.WinTuner.CmdLets/Commands/GetWtToken.cs b/src/Svrooij.WinTuner.CmdLets/Commands/GetWtToken.cs index 0c2f24f..e88e3f8 100644 --- a/src/Svrooij.WinTuner.CmdLets/Commands/GetWtToken.cs +++ b/src/Svrooij.WinTuner.CmdLets/Commands/GetWtToken.cs @@ -1,4 +1,5 @@ using System.IdentityModel.Tokens.Jwt; +using System.Linq; using System.Management.Automation; using System.Threading; using System.Threading.Tasks; @@ -54,7 +55,7 @@ protected override async Task ProcessAuthenticatedAsync(IAuthenticationProvider { // Decode the jwt token and output the claims to the logs var jwt = new JwtSecurityToken(token); - _logger?.LogInformation("Token claims: {@Claims}", jwt.Claims); + _logger?.LogInformation("Token claims: {Claims}", string.Join("\r\n", jwt.Claims.Select(c => $"{c.Type}\t{c.Value}"))); } WriteObject(token); diff --git a/src/Svrooij.WinTuner.CmdLets/Commands/NewWtWingetPackage.cs b/src/Svrooij.WinTuner.CmdLets/Commands/NewWtWingetPackage.cs index bc3a78f..3bd0506 100644 --- a/src/Svrooij.WinTuner.CmdLets/Commands/NewWtWingetPackage.cs +++ b/src/Svrooij.WinTuner.CmdLets/Commands/NewWtWingetPackage.cs @@ -119,6 +119,17 @@ public class NewWtWingetPackage : DependencyCmdlet HelpMessage = "Override the installer arguments")] public string? InstallerArguments { get; set; } + /// + /// Prefered installer type, (default: Msi) + /// + [Parameter( + Mandatory = false, + Position = 9, + ValueFromPipeline = false, + ValueFromPipelineByPropertyName = false, + HelpMessage = "Prefered installer type")] + public WingetIntune.Models.InstallerType PreferedInstaller { get; set; } = WingetIntune.Models.InstallerType.Msi; + [ServiceDependency] private ILogger logger; @@ -164,7 +175,8 @@ public override async Task ProcessRecordAsync(CancellationToken cancellationToke InstallerContext = InstallerContext, PackageScript = PackageScript, Locale = Locale, - OverrideArguments = InstallerArguments + OverrideArguments = InstallerArguments, + InstallerType = PreferedInstaller }, cancellationToken: cancellationToken); diff --git a/src/Svrooij.WinTuner.CmdLets/README.md b/src/Svrooij.WinTuner.CmdLets/README.md index 643cc70..d649067 100644 --- a/src/Svrooij.WinTuner.CmdLets/README.md +++ b/src/Svrooij.WinTuner.CmdLets/README.md @@ -9,6 +9,16 @@ Source of WinTuner PowerShell module, available in the [PowerShell Gallery][link Documentation can be found [here](https://wintuner.app/docs/category/wintuner-powershell). +## Development + +To regenerate the documentation, run the following command from the root of this repo: + +```powershell +# Install the tool +# dotnet tool install --global SvRooij.PowerShell.Docs --version 0.1.1 +PS> pwsh-docs --dll .\src\Svrooij.WinTuner.CmdLets\bin\Debug\net6.0\Svrooij.WinTuner.CmdLets.dll --use-xml-docs --maml-file .\src\Svrooij.WinTuner.CmdLets\Svrooij.WinTuner.CmdLets.dll-Help.xml +``` + [badge_license]: https://img.shields.io/github/license/svrooij/WingetIntune?style=for-the-badge [link_license]: https://github.com/svrooij/WingetIntune/blob/main/LICENSE.txt [badge_powershell]: https://img.shields.io/powershellgallery/v/WinTuner?style=for-the-badge&logo=powershell&logoColor=white diff --git a/src/Svrooij.WinTuner.CmdLets/Svrooij.WinTuner.CmdLets.dll-Help.xml b/src/Svrooij.WinTuner.CmdLets/Svrooij.WinTuner.CmdLets.dll-Help.xml index 1edf94b..dca6b17 100644 --- a/src/Svrooij.WinTuner.CmdLets/Svrooij.WinTuner.CmdLets.dll-Help.xml +++ b/src/Svrooij.WinTuner.CmdLets/Svrooij.WinTuner.CmdLets.dll-Help.xml @@ -1659,6 +1659,31 @@ You could run this on a weekly bases. None + + PreferedInstaller + + Prefered installer type + + + Unknown + Msi + Msix + Appx + Exe + Zip + Inno + Nullsoft + Wix + Burn + Pwa + Portable + + InstallerType + + InstallerType + + None + @@ -1773,6 +1798,31 @@ You could run this on a weekly bases. None + + PreferedInstaller + + Prefered installer type + + + Unknown + Msi + Msix + Appx + Exe + Zip + Inno + Nullsoft + Wix + Burn + Pwa + Portable + + InstallerType + + InstallerType + + None + diff --git a/src/Svrooij.WinTuner.CmdLets/packages.lock.json b/src/Svrooij.WinTuner.CmdLets/packages.lock.json index 0bca5b4..0c15130 100644 --- a/src/Svrooij.WinTuner.CmdLets/packages.lock.json +++ b/src/Svrooij.WinTuner.CmdLets/packages.lock.json @@ -149,45 +149,46 @@ }, "Microsoft.Extensions.DependencyInjection": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==", + "resolved": "8.0.1", + "contentHash": "BmANAnR5Xd4Oqw7yQ75xOAYODybZQRzdeNucg7kS5wWKd2PNnMdYtJ2Vciy0QLylRmv42DGl5+AFL9izA6F1Rw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" + "resolved": "8.0.2", + "contentHash": "3iE7UF7MQkCv1cxzCahz+Y/guQbTqieyxyaWKhrRO91itI9cOKO76OHeQDahqG4MmW5umr3CcCvGmK92lWNlbg==" }, "Microsoft.Extensions.Http": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "cWz4caHwvx0emoYe7NkHPxII/KkTI8R/LC9qdqJqnKv2poTJ4e2qqPGQqvRoQ5kaSA4FU5IV3qFAuLuOhoqULQ==", + "resolved": "8.0.1", + "contentHash": "kDYeKJUzh0qeg/AI+nSr3ffthmXYQTEb0nS9qRC7YhSbbuN4M4NPbaB77AJwtkTnCV9XZ7qYj3dkZaNcyl73EA==", "dependencies": { "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Logging": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "Microsoft.Extensions.Logging": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Logging": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "tvRkov9tAJ3xP51LCv3FJ2zINmv1P8Hi8lhhtcKGqM+ImiTCC84uOPEI4z8Cdq2C3o9e+Aa0Gw0rmrsJD77W+w==", + "resolved": "8.0.1", + "contentHash": "4x+pzsQEbqxhNf1QYRr5TDkLP9UsLT3A6MdRKDDEgrW7h1ljiEPgTNhKYUhNCCAaVpQECVQ+onA91PTPnIp6Lw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.DependencyInjection": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", + "resolved": "8.0.2", + "contentHash": "nroMDjS7hNBPtkZqVBbSiQaQjWRDxITI8Y7XnDs97rqG3EbzVTNLZQf7bIeUJcaHOV8bca47s1Uxq94+2oGdxA==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "System.Diagnostics.DiagnosticSource": "8.0.1" } }, "Microsoft.Extensions.Logging.Configuration": { @@ -692,12 +693,12 @@ }, "SvRooij.ContentPrep": { "type": "Transitive", - "resolved": "0.1.3-alpha0001", - "contentHash": "9exebiAiEz1cn5XKxivypRmpG0t0ykSFrenU8GtwYzv3JrIlkXT6WdntsVYr181ebWhdAWOU4cjR5IgMjDqQMg==", + "resolved": "0.2.2", + "contentHash": "U76+iUs+6ITR/kXNW5ylZj87yQ4UPmqUOConek8Tus16/lfwLNbItGPed8P/wbj/+517FU0pGyFUQiedY4mSfA==", "dependencies": { "Microsoft.Extensions.Logging.Abstractions": "7.0.1", "Microsoft.NETCore.Platforms": "7.0.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" + "System.Runtime.CompilerServices.Unsafe": "6.1.0" } }, "System.ClientModel": { @@ -771,8 +772,8 @@ }, "System.Diagnostics.DiagnosticSource": { "type": "Transitive", - "resolved": "6.0.1", - "contentHash": "KiLYDu2k2J82Q9BJpWiuQqCkFjRBWVq4jDzKKWawVi9KWzyD0XG3cmfX0vqTQlL14Wi9EufJrbL0+KCLTbqWiQ==", + "resolved": "8.0.1", + "contentHash": "vaoWjvkG1aenR2XdjaVivlCV9fADfgyhW5bZtXT23qaEea0lWiUljdQuze4E31vKM7ZWJaSUsbYIKE3rnzfZUg==", "dependencies": { "System.Runtime.CompilerServices.Unsafe": "6.0.0" } @@ -943,8 +944,8 @@ }, "System.Runtime.CompilerServices.Unsafe": { "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + "resolved": "6.1.0", + "contentHash": "5o/HZxx6RVqYlhKSq8/zronDkALJZUT2Vz0hx43f0gwe8mwlM0y2nYlqdBwLMzr262Bwvpikeb/yEwkAa5PADg==" }, "System.Security.AccessControl": { "type": "Transitive", @@ -1108,7 +1109,7 @@ "winget.communityrepository": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.2, )", "YamlDotNet": "[16.0.0, )" } }, @@ -1118,15 +1119,15 @@ "Azure.Core": "[1.44.1, )", "Microsoft.Bcl.AsyncInterfaces": "[8.0.0, )", "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Extensions.Http": "[8.0.0, )", - "Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )", + "Microsoft.Extensions.Http": "[8.0.1, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.2, )", "Microsoft.Extensions.Options": "[8.0.2, )", "Microsoft.Graph.Beta": "[5.78.0-preview, )", "Microsoft.Graph.Core": "[3.2.0, )", "Microsoft.Identity.Client.Broker": "[4.66.2, )", "Microsoft.Identity.Client.Extensions.Msal": "[4.66.2, )", "Riok.Mapperly": "[3.6.0, )", - "SvRooij.ContentPrep": "[0.1.3-alpha0001, )", + "SvRooij.ContentPrep": "[0.2.2, )", "System.IdentityModel.Tokens.Jwt": "[8.0.2, )", "WinTuner.Proxy.Client": "[1.0.0, )", "Winget.CommunityRepository": "[1.0.0, )" @@ -1135,7 +1136,7 @@ "wintuner.proxy.client": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Http": "[8.0.0, )", + "Microsoft.Extensions.Http": "[8.0.1, )", "Microsoft.Kiota.Abstractions": "[1.14.0, )", "Microsoft.Kiota.Http.HttpClientLibrary": "[1.14.0, )", "Microsoft.Kiota.Serialization.Json": "[1.14.0, )", diff --git a/src/WinTuner.Proxy.Client/WinTuner.Proxy.Client.csproj b/src/WinTuner.Proxy.Client/WinTuner.Proxy.Client.csproj index 6e1f2bd..79d8e81 100644 --- a/src/WinTuner.Proxy.Client/WinTuner.Proxy.Client.csproj +++ b/src/WinTuner.Proxy.Client/WinTuner.Proxy.Client.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Winget.CommunityRepository.Ef/Winget.CommunityRepository.Ef.csproj b/src/Winget.CommunityRepository.Ef/Winget.CommunityRepository.Ef.csproj index a51b961..6f00e1f 100644 --- a/src/Winget.CommunityRepository.Ef/Winget.CommunityRepository.Ef.csproj +++ b/src/Winget.CommunityRepository.Ef/Winget.CommunityRepository.Ef.csproj @@ -20,7 +20,9 @@ 1701;1702;CS8618 - + + + diff --git a/src/Winget.CommunityRepository/Winget.CommunityRepository.csproj b/src/Winget.CommunityRepository/Winget.CommunityRepository.csproj index c58dd91..e029bbc 100644 --- a/src/Winget.CommunityRepository/Winget.CommunityRepository.csproj +++ b/src/Winget.CommunityRepository/Winget.CommunityRepository.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/WingetIntune.Cli/WingetIntune.Cli.csproj b/src/WingetIntune.Cli/WingetIntune.Cli.csproj index 71aab45..7e75dce 100644 --- a/src/WingetIntune.Cli/WingetIntune.Cli.csproj +++ b/src/WingetIntune.Cli/WingetIntune.Cli.csproj @@ -42,7 +42,7 @@ - + diff --git a/src/WingetIntune.Cli/packages.lock.json b/src/WingetIntune.Cli/packages.lock.json index cac258a..80e85ed 100644 --- a/src/WingetIntune.Cli/packages.lock.json +++ b/src/WingetIntune.Cli/packages.lock.json @@ -22,18 +22,17 @@ "resolved": "2.6.1", "contentHash": "TyU885plpk88kMxgayy5+QQvtt/t3ZR45+vSvaKqZiaK+YsGVE6Mv7sV3fwjUMv3jHT15DdkpxW/+o+uc+bAJQ==" }, - "Microsoft.Extensions.Http": { + "Microsoft.Extensions.Caching.Memory": { "type": "Direct", - "requested": "[8.0.0, )", - "resolved": "8.0.0", - "contentHash": "cWz4caHwvx0emoYe7NkHPxII/KkTI8R/LC9qdqJqnKv2poTJ4e2qqPGQqvRoQ5kaSA4FU5IV3qFAuLuOhoqULQ==", + "requested": "[8.0.1, )", + "resolved": "8.0.1", + "contentHash": "HFDnhYLccngrzyGgHkjEDU5FMLn4MpOsr5ElgsBMC4yx6lJh4jeWO7fHS8+TXPq+dgxCmUa/Trl8svObmwW4QA==", "dependencies": { - "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Diagnostics": "8.0.0", - "Microsoft.Extensions.Logging": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.Caching.Abstractions": "8.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2", + "Microsoft.Extensions.Primitives": "8.0.0" } }, "System.CommandLine": { @@ -143,18 +142,6 @@ "Microsoft.Extensions.Primitives": "8.0.0" } }, - "Microsoft.Extensions.Caching.Memory": { - "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "7pqivmrZDzo1ADPkRwjy+8jtRKWRCPag9qPI+p7sgu7Q4QreWhcvbiWXsbhP+yY8XSiDvZpu2/LWdBv7PnmOpQ==", - "dependencies": { - "Microsoft.Extensions.Caching.Abstractions": "8.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0", - "Microsoft.Extensions.Primitives": "8.0.0" - } - }, "Microsoft.Extensions.Configuration": { "type": "Transitive", "resolved": "8.0.0", @@ -235,16 +222,16 @@ }, "Microsoft.Extensions.DependencyInjection": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==", + "resolved": "8.0.1", + "contentHash": "BmANAnR5Xd4Oqw7yQ75xOAYODybZQRzdeNucg7kS5wWKd2PNnMdYtJ2Vciy0QLylRmv42DGl5+AFL9izA6F1Rw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" + "resolved": "8.0.2", + "contentHash": "3iE7UF7MQkCv1cxzCahz+Y/guQbTqieyxyaWKhrRO91itI9cOKO76OHeQDahqG4MmW5umr3CcCvGmK92lWNlbg==" }, "Microsoft.Extensions.DependencyModel": { "type": "Transitive", @@ -257,22 +244,21 @@ }, "Microsoft.Extensions.Diagnostics": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "3PZp/YSkIXrF7QK7PfC1bkyRYwqOHpWFad8Qx+4wkuumAeXo1NHaxpS9LboNA9OvNSAu+QOVlXbMyoY+pHSqcw==", + "resolved": "8.0.1", + "contentHash": "doVPCUUCY7c6LhBsEfiy3W1bvS7Mi6LkfQMS8nlC22jZWNxBv8VO8bdfeyvpYFst6Kxqk7HBC6lytmEoBssvSQ==", "dependencies": { "Microsoft.Extensions.Configuration": "8.0.0", - "Microsoft.Extensions.Diagnostics.Abstractions": "8.0.0", + "Microsoft.Extensions.Diagnostics.Abstractions": "8.0.1", "Microsoft.Extensions.Options.ConfigurationExtensions": "8.0.0" } }, "Microsoft.Extensions.Diagnostics.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "JHYCQG7HmugNYUhOl368g+NMxYE/N/AiclCYRNlgCY9eVyiBkOHMwK4x60RYMxv9EL3+rmj1mqHvdCiPpC+D4Q==", + "resolved": "8.0.1", + "contentHash": "elH2vmwNmsXuKmUeMQ4YW9ldXiF+gSGDgg1vORksob5POnpaI6caj1Hu8zaYbEuibhqCoWg0YRWDazBY3zjBfg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0", - "System.Diagnostics.DiagnosticSource": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.FileProviders.Abstractions": { @@ -336,22 +322,35 @@ "Microsoft.Extensions.FileProviders.Abstractions": "6.0.0" } }, + "Microsoft.Extensions.Http": { + "type": "Transitive", + "resolved": "8.0.1", + "contentHash": "kDYeKJUzh0qeg/AI+nSr3ffthmXYQTEb0nS9qRC7YhSbbuN4M4NPbaB77AJwtkTnCV9XZ7qYj3dkZaNcyl73EA==", + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "Microsoft.Extensions.Diagnostics": "8.0.1", + "Microsoft.Extensions.Logging": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" + } + }, "Microsoft.Extensions.Logging": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "tvRkov9tAJ3xP51LCv3FJ2zINmv1P8Hi8lhhtcKGqM+ImiTCC84uOPEI4z8Cdq2C3o9e+Aa0Gw0rmrsJD77W+w==", + "resolved": "8.0.1", + "contentHash": "4x+pzsQEbqxhNf1QYRr5TDkLP9UsLT3A6MdRKDDEgrW7h1ljiEPgTNhKYUhNCCAaVpQECVQ+onA91PTPnIp6Lw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.DependencyInjection": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", + "resolved": "8.0.2", + "contentHash": "nroMDjS7hNBPtkZqVBbSiQaQjWRDxITI8Y7XnDs97rqG3EbzVTNLZQf7bIeUJcaHOV8bca47s1Uxq94+2oGdxA==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, "Microsoft.Extensions.Logging.Configuration": { @@ -614,11 +613,6 @@ "Microsoft.Kiota.Abstractions": "1.14.0" } }, - "Microsoft.NETCore.Platforms": { - "type": "Transitive", - "resolved": "7.0.4", - "contentHash": "yLEHlNN7O5WiND89r42sepgVwy5W/ZoTiFEdJDV7MHR1lW02LL7Nipz2TD5qM/Kx9W3/k3NP+PAP2qUdOm+leg==" - }, "Riok.Mapperly": { "type": "Transitive", "resolved": "3.6.0", @@ -661,12 +655,10 @@ }, "SvRooij.ContentPrep": { "type": "Transitive", - "resolved": "0.1.3-alpha0001", - "contentHash": "9exebiAiEz1cn5XKxivypRmpG0t0ykSFrenU8GtwYzv3JrIlkXT6WdntsVYr181ebWhdAWOU4cjR5IgMjDqQMg==", + "resolved": "0.2.2", + "contentHash": "U76+iUs+6ITR/kXNW5ylZj87yQ4UPmqUOConek8Tus16/lfwLNbItGPed8P/wbj/+517FU0pGyFUQiedY4mSfA==", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "7.0.1", - "Microsoft.NETCore.Platforms": "7.0.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" + "Microsoft.Extensions.Logging.Abstractions": "8.0.0" } }, "System.ClientModel": { @@ -688,8 +680,11 @@ }, "System.Diagnostics.DiagnosticSource": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "c9xLpVz6PL9lp/djOWtk5KPDZq3cSYpmXoJQY524EOtuFl5z9ZtsotpsyrDW40U1DRnQSYvcPKEUV0X//u6gkQ==" + "resolved": "6.0.1", + "contentHash": "KiLYDu2k2J82Q9BJpWiuQqCkFjRBWVq4jDzKKWawVi9KWzyD0XG3cmfX0vqTQlL14Wi9EufJrbL0+KCLTbqWiQ==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } }, "System.Diagnostics.EventLog": { "type": "Transitive", @@ -756,7 +751,7 @@ "winget.communityrepository": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.2, )", "YamlDotNet": "[16.0.0, )" } }, @@ -765,7 +760,9 @@ "dependencies": { "Microsoft.EntityFrameworkCore.Sqlite": "[8.0.4, )", "Microsoft.EntityFrameworkCore.Sqlite.Core": "[8.0.4, )", - "Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )", + "Microsoft.Extensions.Caching.Memory": "[8.0.1, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.2, )", + "System.Text.Json": "[8.0.5, )", "Winget.CommunityRepository": "[1.0.0, )" } }, @@ -775,15 +772,15 @@ "Azure.Core": "[1.44.1, )", "Microsoft.Bcl.AsyncInterfaces": "[8.0.0, )", "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Extensions.Http": "[8.0.0, )", - "Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )", + "Microsoft.Extensions.Http": "[8.0.1, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.2, )", "Microsoft.Extensions.Options": "[8.0.2, )", "Microsoft.Graph.Beta": "[5.78.0-preview, )", "Microsoft.Graph.Core": "[3.2.0, )", "Microsoft.Identity.Client.Broker": "[4.66.2, )", "Microsoft.Identity.Client.Extensions.Msal": "[4.66.2, )", "Riok.Mapperly": "[3.6.0, )", - "SvRooij.ContentPrep": "[0.1.3-alpha0001, )", + "SvRooij.ContentPrep": "[0.2.2, )", "System.IdentityModel.Tokens.Jwt": "[8.0.2, )", "WinTuner.Proxy.Client": "[1.0.0, )", "Winget.CommunityRepository": "[1.0.0, )" @@ -792,7 +789,7 @@ "wintuner.proxy.client": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Http": "[8.0.0, )", + "Microsoft.Extensions.Http": "[8.0.1, )", "Microsoft.Kiota.Abstractions": "[1.14.0, )", "Microsoft.Kiota.Http.HttpClientLibrary": "[1.14.0, )", "Microsoft.Kiota.Serialization.Json": "[1.14.0, )", diff --git a/src/WingetIntune/Commands/ComputeBestInstallerForPackageCommand.cs b/src/WingetIntune/Commands/ComputeBestInstallerForPackageCommand.cs new file mode 100644 index 0000000..487728f --- /dev/null +++ b/src/WingetIntune/Commands/ComputeBestInstallerForPackageCommand.cs @@ -0,0 +1,142 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using WingetIntune.Implementations; +using WingetIntune.Models; + +namespace WingetIntune.Commands; +public partial class ComputeBestInstallerForPackageCommand +{ + private readonly ILogger _logger; + + public ComputeBestInstallerForPackageCommand(ILogger? logger = null) + { + _logger = logger ?? new NullLogger(); + } + + public void Execute(ref PackageInfo package, PackageOptions? packageOptions = null) + { + packageOptions ??= new PackageOptions(); + LogComputingBestInstaller(package.PackageIdentifier!, package.Version!, packageOptions.Architecture); + var installer = package.GetBestInstaller(packageOptions); + if (installer is null) + { + throw new ArgumentException($"No installer found for {package.PackageIdentifier} {package.Version} {packageOptions.Architecture}"); + } + + package.InstallerUrl = new Uri(installer.InstallerUrl!); + package.InstallerFilename = Path.GetFileName(package.InstallerUrl.LocalPath.Replace(" ", "")); + + if (string.IsNullOrEmpty(package.InstallerFilename)) + { + package.InstallerFilename = $"{package.PackageIdentifier}_{package.Version}.{GuessInstallerExtension(installer.ParseInstallerType())}"; + } + + // Maybe this should be done for other installers as well? + if ((installer.InstallerType!.Equals("exe", StringComparison.OrdinalIgnoreCase) || installer.InstallerType!.Equals("burn", StringComparison.OrdinalIgnoreCase)) && package.InstallerFilename!.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) == false) + { + package.InstallerFilename += ".exe"; + } + package.Hash = installer.InstallerSha256; + package.Architecture = installer.InstallerArchitecture(); + package.InstallerContext = installer.ParseInstallerContext() == InstallerContext.Unknown ? (package.InstallerContext ?? packageOptions.InstallerContext) : installer.ParseInstallerContext(); + package.InstallerType = installer.ParseInstallerType(); + package.Installer = installer; + if (!package.InstallerType.IsMsi() || packageOptions.PackageScript) + { + ComputeInstallerCommands(ref package, packageOptions); + } + + package.MsiVersion ??= installer.AppsAndFeaturesEntries?.FirstOrDefault()?.DisplayVersion; + package.MsiProductCode ??= installer.ProductCode ?? installer.AppsAndFeaturesEntries?.FirstOrDefault()?.ProductCode; + } + + private static string GuessInstallerExtension(InstallerType installerType) => installerType switch + { + InstallerType.Inno => "exe", + InstallerType.Msi => "msi", + InstallerType.Msix => "msix", + InstallerType.Appx => "appx", + InstallerType.Burn => "exe", + InstallerType.Wix => "msi", + InstallerType.Nullsoft => "exe", + InstallerType.Exe => "exe", + InstallerType.Zip => "zip", + _ => throw new ArgumentException("Unknown installer type", nameof(installerType)) + }; + + private static readonly Dictionary DefaultInstallerSwitches = new() + { + { InstallerType.Inno, "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" }, + { InstallerType.Burn, "/quiet /norestart /install" }, + { InstallerType.Nullsoft, "/S" }, + }; + + /// + /// Compute the installer commands for the package + /// + /// Package info + /// User-defined options + private void ComputeInstallerCommands(ref PackageInfo package, PackageOptions packageOptions) + { + // If package script is enabled, we will just use the winget install & uninstall commands + // This way your packages in Intune will not contain the installer files + // And it also helps with installers that otherwise would just not install silently or install at all + if (packageOptions.PackageScript != true) + { + string? installerSwitches = packageOptions.OverrideArguments ?? package.Installer?.InstallerSwitches?.GetPreferred(); + switch (package.InstallerType) + { + case InstallerType.Inno: + if (installerSwitches?.Contains("/VERYSILENT") != true) + { + installerSwitches += " " + DefaultInstallerSwitches[InstallerType.Inno]; + installerSwitches = installerSwitches.Trim(); + } + package.InstallCommandLine = $"\"{package.InstallerFilename}\" {installerSwitches}"; + // Don't know the uninstall command + // Configure the uninstall command for Inno Setup + //package.UninstallCommandLine = $"\"{package.InstallerFilename}\" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /D={{0}}"; + break; + + case InstallerType.Burn: + if (installerSwitches?.Contains("/quiet") != true) + { + installerSwitches += " " + DefaultInstallerSwitches[InstallerType.Burn]; + installerSwitches = string.Join(" ", installerSwitches.Split(' ').Distinct()).Trim(); + } + package.InstallCommandLine = $"\"{package.InstallerFilename}\" {installerSwitches}"; + // Have to check the uninstall command + package.UninstallCommandLine = $"\"{package.InstallerFilename}\" /quiet /norestart /uninstall /passive"; // /burn.ignoredependencies=\"{package.PackageIdentifier}\" + break; + + case InstallerType.Nullsoft: + package.InstallCommandLine = $"\"{package.InstallerFilename}\" {installerSwitches ?? DefaultInstallerSwitches[InstallerType.Nullsoft]}"; + break; + + case InstallerType.Exe: + package.InstallCommandLine = $"\"{package.InstallerFilename}\" {installerSwitches}"; + // Have to check the uninstall command + //package.UninstallCommandLine = $"\"{package.InstallerFilename}\" /quiet /norestart /uninstall /passive"; // /burn.ignoredependencies=\"{package.PackageIdentifier}\" + break; + } + } + + // If the installer type is unsupported or the package script is enabled, we will generate a script to install the package + if (string.IsNullOrWhiteSpace(package.InstallCommandLine)) + { + var installArguments = WingetHelper.GetInstallArgumentsForPackage(package.PackageIdentifier!, package.Version, installerContext: package.InstallerContext ?? InstallerContext.Unknown); + // This seems like a hack I know, but it's the only way to get the install command for now. + package.InstallCommandLine = $"winget {installArguments}"; + } + + // Uninstall command is almost always empty, so we just use winget to uninstall the package + if (string.IsNullOrWhiteSpace(package.UninstallCommandLine)) + { + var uninstallArguments = WingetHelper.GetUninstallArgumentsForPackage(package.PackageIdentifier!, installerContext: package.InstallerContext ?? InstallerContext.Unknown); + package.UninstallCommandLine = $"winget {uninstallArguments}"; + } + } + + [LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Computing best installer for {PackageIdentifier} {Version} {Architecture}")] + private partial void LogComputingBestInstaller(string PackageIdentifier, string Version, Architecture Architecture); +} diff --git a/src/WingetIntune/Graph/GraphAppUploader.cs b/src/WingetIntune/Graph/GraphAppUploader.cs index 24bdfc7..f5fa335 100644 --- a/src/WingetIntune/Graph/GraphAppUploader.cs +++ b/src/WingetIntune/Graph/GraphAppUploader.cs @@ -85,7 +85,8 @@ public GraphAppUploader(ILogger logger, IFileManager fileManag { try { - await graphServiceClient.DeviceAppManagement.MobileApps[appId].DeleteAsync(cancellationToken: cancellationToken); + // Do not use the cancellationToken here, we want to delete the app no matter what. + await graphServiceClient.DeviceAppManagement.MobileApps[appId].DeleteAsync(cancellationToken: CancellationToken.None); } catch (Exception ex2) { diff --git a/src/WingetIntune/Intune/IntuneManager.cs b/src/WingetIntune/Intune/IntuneManager.cs index c8c1953..a478d84 100644 --- a/src/WingetIntune/Intune/IntuneManager.cs +++ b/src/WingetIntune/Intune/IntuneManager.cs @@ -7,8 +7,8 @@ using Microsoft.Kiota.Abstractions.Serialization; using System.Text; using System.Text.Json; +using WingetIntune.Commands; using WingetIntune.Graph; -using WingetIntune.Implementations; using WingetIntune.Interfaces; using WingetIntune.Internal.Msal; using WingetIntune.Intune; @@ -31,8 +31,9 @@ public partial class IntuneManager private readonly PublicClientAuth publicClient; private readonly GraphAppUploader graphAppUploader; private readonly GraphStoreAppUploader graphStoreAppUploader; + private readonly ComputeBestInstallerForPackageCommand computeBestInstallerForPackageCommand; - public IntuneManager(ILoggerFactory? loggerFactory, IFileManager fileManager, IProcessManager processManager, HttpClient httpClient, IAzureFileUploader azureFileUploader, PublicClientAuth publicClient, IIntunePackager intunePackager, IWingetRepository wingetRepository, GraphAppUploader graphAppUploader, GraphStoreAppUploader graphStoreAppUploader) + public IntuneManager(ILoggerFactory? loggerFactory, IFileManager fileManager, IProcessManager processManager, HttpClient httpClient, IAzureFileUploader azureFileUploader, PublicClientAuth publicClient, IIntunePackager intunePackager, IWingetRepository wingetRepository, GraphAppUploader graphAppUploader, GraphStoreAppUploader graphStoreAppUploader, ComputeBestInstallerForPackageCommand computeBestInstallerForPackageCommand) { this.loggerFactory = loggerFactory ?? new NullLoggerFactory(); this.logger = this.loggerFactory.CreateLogger(); @@ -45,6 +46,7 @@ public IntuneManager(ILoggerFactory? loggerFactory, IFileManager fileManager, IP this.wingetRepository = wingetRepository; this.graphAppUploader = graphAppUploader; this.graphStoreAppUploader = graphStoreAppUploader; + this.computeBestInstallerForPackageCommand = computeBestInstallerForPackageCommand; } public async Task GenerateMsiPackage(string tempFolder, string outputFolder, Models.PackageInfo packageInfo, PackageOptions packageOptions, CancellationToken cancellationToken = default) @@ -61,7 +63,7 @@ public IntuneManager(ILoggerFactory? loggerFactory, IFileManager fileManager, IP } if (packageInfo.Architecture == Architecture.Unknown) { - ComputeInstallerDetails(ref packageInfo, packageOptions); + computeBestInstallerForPackageCommand.Execute(ref packageInfo, packageOptions); } LogGeneratePackage(packageInfo.PackageIdentifier!, packageInfo.Version!, packageInfo.Architecture, packageInfo.InstallerContext, outputFolder); var packageTempFolder = fileManager.CreateFolderForPackage(tempFolder, packageInfo.PackageIdentifier!, packageInfo.Version!); @@ -107,7 +109,7 @@ public IntuneManager(ILoggerFactory? loggerFactory, IFileManager fileManager, IP packageInfo = await wingetRepository.GetPackageInfoAsync(packageInfo.PackageIdentifier!, packageInfo.Version, "winget", cancellationToken); } - ComputeInstallerDetails(ref packageInfo, packageOptions); + computeBestInstallerForPackageCommand.Execute(ref packageInfo, packageOptions); if (packageInfo.InstallerType.IsMsi() && !packageOptions.PackageScript) { @@ -504,130 +506,8 @@ private void LoadMsiDetails(string installerPath, ref PackageInfo packageInfo) packageInfo.UninstallCommandLine = $"msiexec /x {packageInfo.MsiProductCode!} /qn /norestart"; } - private void ComputeInstallerDetails(ref PackageInfo package, PackageOptions packageOptions) - { - var installer = package.GetBestInstaller(packageOptions); - if (installer is null) - { - throw new ArgumentException($"No installer found for {package.PackageIdentifier} {package.Version} {packageOptions.Architecture}"); - } - - package.InstallerUrl = new Uri(installer.InstallerUrl!); - package.InstallerFilename = Path.GetFileName(package.InstallerUrl.LocalPath.Replace(" ", "")); - - if (string.IsNullOrEmpty(package.InstallerFilename)) - { - package.InstallerFilename = $"{package.PackageIdentifier}_{package.Version}.{GuessInstallerExtension(installer.ParseInstallerType())}"; - } - - // Maybe this should be done for other installers as well? - if ((installer.InstallerType!.Equals("exe", StringComparison.OrdinalIgnoreCase) || installer.InstallerType!.Equals("burn", StringComparison.OrdinalIgnoreCase)) && package.InstallerFilename!.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) == false) - { - package.InstallerFilename += ".exe"; - } - package.Hash = installer.InstallerSha256; - package.Architecture = installer.InstallerArchitecture(); - package.InstallerContext = installer.ParseInstallerContext() == InstallerContext.Unknown ? (package.InstallerContext ?? packageOptions.InstallerContext) : installer.ParseInstallerContext(); - package.InstallerType = installer.ParseInstallerType(); - package.Installer = installer; - if (!package.InstallerType.IsMsi() || packageOptions.PackageScript) - { - ComputeInstallerCommands(ref package, packageOptions); - } - - package.MsiVersion ??= installer.AppsAndFeaturesEntries?.FirstOrDefault()?.DisplayVersion; - package.MsiProductCode ??= installer.ProductCode ?? installer.AppsAndFeaturesEntries?.FirstOrDefault()?.ProductCode; - - } - private static readonly InstallerType[] SupportedInstallers = new[] { InstallerType.Inno, InstallerType.Msi, InstallerType.Burn, InstallerType.Wix, InstallerType.Nullsoft, InstallerType.Exe }; - private static string GuessInstallerExtension(InstallerType installerType) => installerType switch - { - InstallerType.Inno => "exe", - InstallerType.Msi => "msi", - InstallerType.Msix => "msix", - InstallerType.Appx => "appx", - InstallerType.Burn => "exe", - InstallerType.Wix => "msi", - InstallerType.Nullsoft => "exe", - InstallerType.Exe => "exe", - InstallerType.Zip => "zip", - _ => throw new ArgumentException("Unknown installer type", nameof(installerType)) - }; - private static readonly Dictionary DefaultInstallerSwitches = new() - { - { InstallerType.Inno, "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-" }, - { InstallerType.Burn, "/quiet /norestart /install" }, - { InstallerType.Nullsoft, "/S" }, - }; - - /// - /// Compute the installer commands for the package - /// - /// Package info - /// User-defined options - private void ComputeInstallerCommands(ref PackageInfo package, PackageOptions packageOptions) - { - // If package script is enabled, we will just use the winget install & uninstall commands - // This way your packages in Intune will not contain the installer files - // And it also helps with installers that otherwise would just not install silently or install at all - if (packageOptions.PackageScript != true) - { - string? installerSwitches = packageOptions.OverrideArguments ?? package.Installer?.InstallerSwitches?.GetPreferred(); - switch (package.InstallerType) - { - case InstallerType.Inno: - if (installerSwitches?.Contains("/VERYSILENT") != true) - { - installerSwitches += " " + DefaultInstallerSwitches[InstallerType.Inno]; - installerSwitches = installerSwitches.Trim(); - } - package.InstallCommandLine = $"\"{package.InstallerFilename}\" {installerSwitches}"; - // Don't know the uninstall command - // Configure the uninstall command for Inno Setup - //package.UninstallCommandLine = $"\"{package.InstallerFilename}\" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /D={{0}}"; - break; - - case InstallerType.Burn: - if (installerSwitches?.Contains("/quiet") != true) - { - installerSwitches += " " + DefaultInstallerSwitches[InstallerType.Burn]; - installerSwitches = string.Join(" ", installerSwitches.Split(' ').Distinct()).Trim(); - } - package.InstallCommandLine = $"\"{package.InstallerFilename}\" {installerSwitches}"; - // Have to check the uninstall command - package.UninstallCommandLine = $"\"{package.InstallerFilename}\" /quiet /norestart /uninstall /passive"; // /burn.ignoredependencies=\"{package.PackageIdentifier}\" - break; - - case InstallerType.Nullsoft: - package.InstallCommandLine = $"\"{package.InstallerFilename}\" {installerSwitches ?? DefaultInstallerSwitches[InstallerType.Nullsoft]}"; - break; - - case InstallerType.Exe: - package.InstallCommandLine = $"\"{package.InstallerFilename}\" {installerSwitches}"; - // Have to check the uninstall command - //package.UninstallCommandLine = $"\"{package.InstallerFilename}\" /quiet /norestart /uninstall /passive"; // /burn.ignoredependencies=\"{package.PackageIdentifier}\" - break; - } - } - - // If the installer type is unsupported or the package script is enabled, we will generate a script to install the package - if (string.IsNullOrWhiteSpace(package.InstallCommandLine)) - { - var installArguments = WingetHelper.GetInstallArgumentsForPackage(package.PackageIdentifier!, package.Version, installerContext: package.InstallerContext ?? InstallerContext.Unknown); - // This seems like a hack I know, but it's the only way to get the install command for now. - package.InstallCommandLine = $"winget {installArguments}"; - } - - // Uninstall command is almost always empty, so we just use winget to uninstall the package - if (string.IsNullOrWhiteSpace(package.UninstallCommandLine)) - { - var uninstallArguments = WingetHelper.GetUninstallArgumentsForPackage(package.PackageIdentifier!, installerContext: package.InstallerContext ?? InstallerContext.Unknown); - package.UninstallCommandLine = $"winget {uninstallArguments}"; - } - } - private async Task WriteReadmeAsync(string packageFolder, PackageInfo packageInfo, CancellationToken cancellationToken) { var sb = new StringBuilder(); diff --git a/src/WingetIntune/Models/PackageInfo.cs b/src/WingetIntune/Models/PackageInfo.cs index bb5912b..f5c614a 100644 --- a/src/WingetIntune/Models/PackageInfo.cs +++ b/src/WingetIntune/Models/PackageInfo.cs @@ -31,11 +31,11 @@ public class PackageInfo public string? DetectionScript { get; set; } - internal WingetInstaller? GetBestFit(Architecture architecture, InstallerContext context, string? locale = null) + internal WingetInstaller? GetBestFit(Architecture architecture, InstallerContext context, string? locale = null, InstallerType installerType = InstallerType.Msi) { if (Installers is null) { return null; } - return Installers.SingleOrDefault(Models.InstallerType.Msi, architecture, context, locale) - ?? Installers.SingleOrDefault(Models.InstallerType.Msi, architecture, Models.InstallerContext.Unknown, locale) + return Installers.SingleOrDefault(installerType, architecture, context, locale) + ?? Installers.SingleOrDefault(installerType, architecture, Models.InstallerContext.Unknown, locale) ?? Installers.SingleOrDefault(Models.InstallerType.Wix, architecture, context, locale) ?? Installers.SingleOrDefault(Models.InstallerType.Wix, architecture, Models.InstallerContext.Unknown, locale) ?? Installers.SingleOrDefault(Models.InstallerType.Unknown, architecture, context, locale) @@ -46,15 +46,15 @@ public class PackageInfo internal WingetInstaller? GetBestInstaller(PackageOptions packageOptions) { if (Installers is null) { return null; } - var installer = GetBestFit(packageOptions.Architecture, packageOptions.InstallerContext, packageOptions.Locale) - ?? GetBestFit(Models.Architecture.Neutral, Models.InstallerContext.Unknown, packageOptions.Locale) - ?? GetBestFit(Models.Architecture.Neutral, packageOptions.InstallerContext, packageOptions.Locale) - ?? GetBestFit(packageOptions.Architecture, Models.InstallerContext.Unknown, packageOptions.Locale); + var installer = GetBestFit(packageOptions.Architecture, packageOptions.InstallerContext, packageOptions.Locale, installerType: packageOptions.InstallerType) + ?? GetBestFit(Models.Architecture.Neutral, Models.InstallerContext.Unknown, packageOptions.Locale, installerType: packageOptions.InstallerType) + ?? GetBestFit(Models.Architecture.Neutral, packageOptions.InstallerContext, packageOptions.Locale, installerType: packageOptions.InstallerType) + ?? GetBestFit(packageOptions.Architecture, Models.InstallerContext.Unknown, packageOptions.Locale, installerType: packageOptions.InstallerType); // if the installer is still null and we are not explicitly looking for arm64 or x64, try x86 if (installer == null && packageOptions.Architecture != WingetIntune.Models.Architecture.X64 && packageOptions.Architecture != Models.Architecture.Arm64) { - installer = GetBestFit(Models.Architecture.X86, packageOptions.InstallerContext) - ?? GetBestFit(Models.Architecture.X86, Models.InstallerContext.Unknown); + installer = GetBestFit(Models.Architecture.X86, packageOptions.InstallerContext, packageOptions.Locale, installerType: packageOptions.InstallerType) + ?? GetBestFit(Models.Architecture.X86, Models.InstallerContext.Unknown, packageOptions.Locale, installerType: packageOptions.InstallerType); } return installer; } diff --git a/src/WingetIntune/Models/PackageOptions.cs b/src/WingetIntune/Models/PackageOptions.cs index 72f9b03..6a3cda2 100644 --- a/src/WingetIntune/Models/PackageOptions.cs +++ b/src/WingetIntune/Models/PackageOptions.cs @@ -2,6 +2,7 @@ public class PackageOptions { + public InstallerType InstallerType { get; init; } = InstallerType.Msi; public InstallerContext InstallerContext { get; init; } public Architecture Architecture { get; init; } public bool PackageScript { get; init; } diff --git a/src/WingetIntune/WingetIntune.csproj b/src/WingetIntune/WingetIntune.csproj index 9e64bde..b319d4c 100644 --- a/src/WingetIntune/WingetIntune.csproj +++ b/src/WingetIntune/WingetIntune.csproj @@ -27,15 +27,15 @@ - - + + - + diff --git a/src/WingetIntune/WingetServiceCollectionExtension.cs b/src/WingetIntune/WingetServiceCollectionExtension.cs index a68fd74..7e4b134 100644 --- a/src/WingetIntune/WingetServiceCollectionExtension.cs +++ b/src/WingetIntune/WingetServiceCollectionExtension.cs @@ -56,6 +56,7 @@ public static IServiceCollection AddWingetServices(this IServiceCollection servi services.AddSingleton(); services.AddSingleton(); services.AddTransient(); + services.AddTransient(); services.AddWinTunerProxyClient(config => { diff --git a/src/WingetIntune/packages.lock.json b/src/WingetIntune/packages.lock.json index 555e949..b81703a 100644 --- a/src/WingetIntune/packages.lock.json +++ b/src/WingetIntune/packages.lock.json @@ -32,24 +32,25 @@ }, "Microsoft.Extensions.Http": { "type": "Direct", - "requested": "[8.0.0, )", - "resolved": "8.0.0", - "contentHash": "cWz4caHwvx0emoYe7NkHPxII/KkTI8R/LC9qdqJqnKv2poTJ4e2qqPGQqvRoQ5kaSA4FU5IV3qFAuLuOhoqULQ==", + "requested": "[8.0.1, )", + "resolved": "8.0.1", + "contentHash": "kDYeKJUzh0qeg/AI+nSr3ffthmXYQTEb0nS9qRC7YhSbbuN4M4NPbaB77AJwtkTnCV9XZ7qYj3dkZaNcyl73EA==", "dependencies": { "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Logging": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "Microsoft.Extensions.Logging": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Direct", - "requested": "[8.0.1, )", - "resolved": "8.0.1", - "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", + "requested": "[8.0.2, )", + "resolved": "8.0.2", + "contentHash": "nroMDjS7hNBPtkZqVBbSiQaQjWRDxITI8Y7XnDs97rqG3EbzVTNLZQf7bIeUJcaHOV8bca47s1Uxq94+2oGdxA==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "System.Diagnostics.DiagnosticSource": "8.0.1" } }, "Microsoft.Extensions.Options": { @@ -116,13 +117,13 @@ }, "SvRooij.ContentPrep": { "type": "Direct", - "requested": "[0.1.3-alpha0001, )", - "resolved": "0.1.3-alpha0001", - "contentHash": "9exebiAiEz1cn5XKxivypRmpG0t0ykSFrenU8GtwYzv3JrIlkXT6WdntsVYr181ebWhdAWOU4cjR5IgMjDqQMg==", + "requested": "[0.2.2, )", + "resolved": "0.2.2", + "contentHash": "U76+iUs+6ITR/kXNW5ylZj87yQ4UPmqUOConek8Tus16/lfwLNbItGPed8P/wbj/+517FU0pGyFUQiedY4mSfA==", "dependencies": { "Microsoft.Extensions.Logging.Abstractions": "7.0.1", "Microsoft.NETCore.Platforms": "7.0.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" + "System.Runtime.CompilerServices.Unsafe": "6.1.0" } }, "System.IdentityModel.Tokens.Jwt": { @@ -145,25 +146,25 @@ }, "Microsoft.Extensions.DependencyInjection": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==", + "resolved": "8.0.1", + "contentHash": "BmANAnR5Xd4Oqw7yQ75xOAYODybZQRzdeNucg7kS5wWKd2PNnMdYtJ2Vciy0QLylRmv42DGl5+AFL9izA6F1Rw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" + "resolved": "8.0.2", + "contentHash": "3iE7UF7MQkCv1cxzCahz+Y/guQbTqieyxyaWKhrRO91itI9cOKO76OHeQDahqG4MmW5umr3CcCvGmK92lWNlbg==" }, "Microsoft.Extensions.Logging": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "tvRkov9tAJ3xP51LCv3FJ2zINmv1P8Hi8lhhtcKGqM+ImiTCC84uOPEI4z8Cdq2C3o9e+Aa0Gw0rmrsJD77W+w==", + "resolved": "8.0.1", + "contentHash": "4x+pzsQEbqxhNf1QYRr5TDkLP9UsLT3A6MdRKDDEgrW7h1ljiEPgTNhKYUhNCCAaVpQECVQ+onA91PTPnIp6Lw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.DependencyInjection": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Primitives": { @@ -323,8 +324,8 @@ }, "System.Diagnostics.DiagnosticSource": { "type": "Transitive", - "resolved": "6.0.1", - "contentHash": "KiLYDu2k2J82Q9BJpWiuQqCkFjRBWVq4jDzKKWawVi9KWzyD0XG3cmfX0vqTQlL14Wi9EufJrbL0+KCLTbqWiQ==", + "resolved": "8.0.1", + "contentHash": "vaoWjvkG1aenR2XdjaVivlCV9fADfgyhW5bZtXT23qaEea0lWiUljdQuze4E31vKM7ZWJaSUsbYIKE3rnzfZUg==", "dependencies": { "System.Runtime.CompilerServices.Unsafe": "6.0.0" } @@ -344,8 +345,8 @@ }, "System.Runtime.CompilerServices.Unsafe": { "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" + "resolved": "6.1.0", + "contentHash": "5o/HZxx6RVqYlhKSq8/zronDkALJZUT2Vz0hx43f0gwe8mwlM0y2nYlqdBwLMzr262Bwvpikeb/yEwkAa5PADg==" }, "System.Security.Cryptography.ProtectedData": { "type": "Transitive", @@ -382,14 +383,14 @@ "winget.communityrepository": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.2, )", "YamlDotNet": "[16.0.0, )" } }, "wintuner.proxy.client": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Http": "[8.0.0, )", + "Microsoft.Extensions.Http": "[8.0.1, )", "Microsoft.Kiota.Abstractions": "[1.14.0, )", "Microsoft.Kiota.Http.HttpClientLibrary": "[1.14.0, )", "Microsoft.Kiota.Serialization.Json": "[1.14.0, )", @@ -428,25 +429,25 @@ }, "Microsoft.Extensions.Http": { "type": "Direct", - "requested": "[8.0.0, )", - "resolved": "8.0.0", - "contentHash": "cWz4caHwvx0emoYe7NkHPxII/KkTI8R/LC9qdqJqnKv2poTJ4e2qqPGQqvRoQ5kaSA4FU5IV3qFAuLuOhoqULQ==", + "requested": "[8.0.1, )", + "resolved": "8.0.1", + "contentHash": "kDYeKJUzh0qeg/AI+nSr3ffthmXYQTEb0nS9qRC7YhSbbuN4M4NPbaB77AJwtkTnCV9XZ7qYj3dkZaNcyl73EA==", "dependencies": { "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Diagnostics": "8.0.0", - "Microsoft.Extensions.Logging": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "Microsoft.Extensions.Diagnostics": "8.0.1", + "Microsoft.Extensions.Logging": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Direct", - "requested": "[8.0.1, )", - "resolved": "8.0.1", - "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", + "requested": "[8.0.2, )", + "resolved": "8.0.2", + "contentHash": "nroMDjS7hNBPtkZqVBbSiQaQjWRDxITI8Y7XnDs97rqG3EbzVTNLZQf7bIeUJcaHOV8bca47s1Uxq94+2oGdxA==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, "Microsoft.Extensions.Options": { @@ -513,13 +514,11 @@ }, "SvRooij.ContentPrep": { "type": "Direct", - "requested": "[0.1.3-alpha0001, )", - "resolved": "0.1.3-alpha0001", - "contentHash": "9exebiAiEz1cn5XKxivypRmpG0t0ykSFrenU8GtwYzv3JrIlkXT6WdntsVYr181ebWhdAWOU4cjR5IgMjDqQMg==", + "requested": "[0.2.2, )", + "resolved": "0.2.2", + "contentHash": "U76+iUs+6ITR/kXNW5ylZj87yQ4UPmqUOConek8Tus16/lfwLNbItGPed8P/wbj/+517FU0pGyFUQiedY4mSfA==", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "7.0.1", - "Microsoft.NETCore.Platforms": "7.0.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" + "Microsoft.Extensions.Logging.Abstractions": "8.0.0" } }, "System.IdentityModel.Tokens.Jwt": { @@ -559,45 +558,44 @@ }, "Microsoft.Extensions.DependencyInjection": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==", + "resolved": "8.0.1", + "contentHash": "BmANAnR5Xd4Oqw7yQ75xOAYODybZQRzdeNucg7kS5wWKd2PNnMdYtJ2Vciy0QLylRmv42DGl5+AFL9izA6F1Rw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" + "resolved": "8.0.2", + "contentHash": "3iE7UF7MQkCv1cxzCahz+Y/guQbTqieyxyaWKhrRO91itI9cOKO76OHeQDahqG4MmW5umr3CcCvGmK92lWNlbg==" }, "Microsoft.Extensions.Diagnostics": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "3PZp/YSkIXrF7QK7PfC1bkyRYwqOHpWFad8Qx+4wkuumAeXo1NHaxpS9LboNA9OvNSAu+QOVlXbMyoY+pHSqcw==", + "resolved": "8.0.1", + "contentHash": "doVPCUUCY7c6LhBsEfiy3W1bvS7Mi6LkfQMS8nlC22jZWNxBv8VO8bdfeyvpYFst6Kxqk7HBC6lytmEoBssvSQ==", "dependencies": { "Microsoft.Extensions.Configuration": "8.0.0", - "Microsoft.Extensions.Diagnostics.Abstractions": "8.0.0", + "Microsoft.Extensions.Diagnostics.Abstractions": "8.0.1", "Microsoft.Extensions.Options.ConfigurationExtensions": "8.0.0" } }, "Microsoft.Extensions.Diagnostics.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "JHYCQG7HmugNYUhOl368g+NMxYE/N/AiclCYRNlgCY9eVyiBkOHMwK4x60RYMxv9EL3+rmj1mqHvdCiPpC+D4Q==", + "resolved": "8.0.1", + "contentHash": "elH2vmwNmsXuKmUeMQ4YW9ldXiF+gSGDgg1vORksob5POnpaI6caj1Hu8zaYbEuibhqCoWg0YRWDazBY3zjBfg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0", - "System.Diagnostics.DiagnosticSource": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Logging": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "tvRkov9tAJ3xP51LCv3FJ2zINmv1P8Hi8lhhtcKGqM+ImiTCC84uOPEI4z8Cdq2C3o9e+Aa0Gw0rmrsJD77W+w==", + "resolved": "8.0.1", + "contentHash": "4x+pzsQEbqxhNf1QYRr5TDkLP9UsLT3A6MdRKDDEgrW7h1ljiEPgTNhKYUhNCCAaVpQECVQ+onA91PTPnIp6Lw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.DependencyInjection": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Options.ConfigurationExtensions": { @@ -745,11 +743,6 @@ "Microsoft.Kiota.Abstractions": "1.14.0" } }, - "Microsoft.NETCore.Platforms": { - "type": "Transitive", - "resolved": "7.0.4", - "contentHash": "yLEHlNN7O5WiND89r42sepgVwy5W/ZoTiFEdJDV7MHR1lW02LL7Nipz2TD5qM/Kx9W3/k3NP+PAP2qUdOm+leg==" - }, "Std.UriTemplate": { "type": "Transitive", "resolved": "2.0.0", @@ -766,8 +759,11 @@ }, "System.Diagnostics.DiagnosticSource": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "c9xLpVz6PL9lp/djOWtk5KPDZq3cSYpmXoJQY524EOtuFl5z9ZtsotpsyrDW40U1DRnQSYvcPKEUV0X//u6gkQ==" + "resolved": "6.0.1", + "contentHash": "KiLYDu2k2J82Q9BJpWiuQqCkFjRBWVq4jDzKKWawVi9KWzyD0XG3cmfX0vqTQlL14Wi9EufJrbL0+KCLTbqWiQ==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } }, "System.Memory.Data": { "type": "Transitive", @@ -818,14 +814,14 @@ "winget.communityrepository": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.2, )", "YamlDotNet": "[16.0.0, )" } }, "wintuner.proxy.client": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Http": "[8.0.0, )", + "Microsoft.Extensions.Http": "[8.0.1, )", "Microsoft.Kiota.Abstractions": "[1.14.0, )", "Microsoft.Kiota.Http.HttpClientLibrary": "[1.14.0, )", "Microsoft.Kiota.Serialization.Json": "[1.14.0, )", diff --git a/tests/WingetIntune.Tests/Intune/IntuneManagerTests.cs b/tests/WingetIntune.Tests/Intune/IntuneManagerTests.cs index 91f621d..d2edb9f 100644 --- a/tests/WingetIntune.Tests/Intune/IntuneManagerTests.cs +++ b/tests/WingetIntune.Tests/Intune/IntuneManagerTests.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging.Abstractions; using System.Runtime.InteropServices; using Winget.CommunityRepository.Models; +using WingetIntune.Commands; using WingetIntune.Interfaces; using WingetIntune.Models; @@ -11,7 +12,7 @@ public class IntuneManagerTests [Fact] public async Task GenerateMsiPackage_OtherPackage_ThrowsError() { - var intuneManager = new IntuneManager(null, null, null, null, null, null, null, null, null, null); + var intuneManager = new IntuneManager(null, null, null, null, null, null, null, null, null, null, new ComputeBestInstallerForPackageCommand()); var tempFolder = Path.Combine(Path.GetTempPath(), "intunewin"); var outputFolder = Path.Combine(Path.GetTempPath(), "packages"); @@ -80,7 +81,7 @@ public async Task GenerateInstallerPackage_MsiPackage_Returns() var intunePackager = Substitute.For(); - var intuneManager = new IntuneManager(new NullLoggerFactory(), fileManager, processManager, null, null, null, intunePackager, null, null, null); + var intuneManager = new IntuneManager(new NullLoggerFactory(), fileManager, processManager, null, null, null, intunePackager, null, null, null, new ComputeBestInstallerForPackageCommand()); await intuneManager.GenerateInstallerPackage(tempFolder, outputFolder, IntuneTestConstants.azureCliPackageInfo, new PackageOptions { Architecture = Models.Architecture.X64, InstallerContext = InstallerContext.User }, CancellationToken.None); @@ -105,7 +106,7 @@ public async Task DownloadLogoAsync_CallsFilemanager() fileManager.DownloadFileAsync($"https://api.winstall.app/icons/{packageId}.png", logoPath, null, false, false, Arg.Any()) .Returns(Task.CompletedTask); - var intuneManager = new IntuneManager(new NullLoggerFactory(), fileManager, null, null, null, null, null, null, null, null); + var intuneManager = new IntuneManager(new NullLoggerFactory(), fileManager, null, null, null, null, null, null, null, null, new ComputeBestInstallerForPackageCommand()); await intuneManager.DownloadLogoAsync(folder, packageId, CancellationToken.None); //call.Received(1); @@ -137,7 +138,7 @@ public async Task DownloadInstallerAsync_CallsFilemanager() fileManager.DownloadFileAsync(packageInfo.InstallerUrl.ToString(), installerPath, hash, true, false, Arg.Any()) .Returns(Task.CompletedTask); - var intuneManager = new IntuneManager(new NullLoggerFactory(), fileManager, null, null, null, null, null, null, null, null); + var intuneManager = new IntuneManager(new NullLoggerFactory(), fileManager, null, null, null, null, null, null, null, null, new ComputeBestInstallerForPackageCommand()); await intuneManager.DownloadInstallerAsync(folder, packageInfo, CancellationToken.None); //call.Received(1); diff --git a/tests/WingetIntune.Tests/packages.lock.json b/tests/WingetIntune.Tests/packages.lock.json index 62a546a..bef9209 100644 --- a/tests/WingetIntune.Tests/packages.lock.json +++ b/tests/WingetIntune.Tests/packages.lock.json @@ -124,66 +124,65 @@ }, "Microsoft.Extensions.DependencyInjection": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==", + "resolved": "8.0.1", + "contentHash": "BmANAnR5Xd4Oqw7yQ75xOAYODybZQRzdeNucg7kS5wWKd2PNnMdYtJ2Vciy0QLylRmv42DGl5+AFL9izA6F1Rw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" + "resolved": "8.0.2", + "contentHash": "3iE7UF7MQkCv1cxzCahz+Y/guQbTqieyxyaWKhrRO91itI9cOKO76OHeQDahqG4MmW5umr3CcCvGmK92lWNlbg==" }, "Microsoft.Extensions.Diagnostics": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "3PZp/YSkIXrF7QK7PfC1bkyRYwqOHpWFad8Qx+4wkuumAeXo1NHaxpS9LboNA9OvNSAu+QOVlXbMyoY+pHSqcw==", + "resolved": "8.0.1", + "contentHash": "doVPCUUCY7c6LhBsEfiy3W1bvS7Mi6LkfQMS8nlC22jZWNxBv8VO8bdfeyvpYFst6Kxqk7HBC6lytmEoBssvSQ==", "dependencies": { "Microsoft.Extensions.Configuration": "8.0.0", - "Microsoft.Extensions.Diagnostics.Abstractions": "8.0.0", + "Microsoft.Extensions.Diagnostics.Abstractions": "8.0.1", "Microsoft.Extensions.Options.ConfigurationExtensions": "8.0.0" } }, "Microsoft.Extensions.Diagnostics.Abstractions": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "JHYCQG7HmugNYUhOl368g+NMxYE/N/AiclCYRNlgCY9eVyiBkOHMwK4x60RYMxv9EL3+rmj1mqHvdCiPpC+D4Q==", + "resolved": "8.0.1", + "contentHash": "elH2vmwNmsXuKmUeMQ4YW9ldXiF+gSGDgg1vORksob5POnpaI6caj1Hu8zaYbEuibhqCoWg0YRWDazBY3zjBfg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0", - "System.Diagnostics.DiagnosticSource": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Http": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "cWz4caHwvx0emoYe7NkHPxII/KkTI8R/LC9qdqJqnKv2poTJ4e2qqPGQqvRoQ5kaSA4FU5IV3qFAuLuOhoqULQ==", + "resolved": "8.0.1", + "contentHash": "kDYeKJUzh0qeg/AI+nSr3ffthmXYQTEb0nS9qRC7YhSbbuN4M4NPbaB77AJwtkTnCV9XZ7qYj3dkZaNcyl73EA==", "dependencies": { "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Diagnostics": "8.0.0", - "Microsoft.Extensions.Logging": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2", + "Microsoft.Extensions.Diagnostics": "8.0.1", + "Microsoft.Extensions.Logging": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Logging": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "tvRkov9tAJ3xP51LCv3FJ2zINmv1P8Hi8lhhtcKGqM+ImiTCC84uOPEI4z8Cdq2C3o9e+Aa0Gw0rmrsJD77W+w==", + "resolved": "8.0.1", + "contentHash": "4x+pzsQEbqxhNf1QYRr5TDkLP9UsLT3A6MdRKDDEgrW7h1ljiEPgTNhKYUhNCCAaVpQECVQ+onA91PTPnIp6Lw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection": "8.0.0", - "Microsoft.Extensions.Logging.Abstractions": "8.0.0", - "Microsoft.Extensions.Options": "8.0.0" + "Microsoft.Extensions.DependencyInjection": "8.0.1", + "Microsoft.Extensions.Logging.Abstractions": "8.0.2", + "Microsoft.Extensions.Options": "8.0.2" } }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", + "resolved": "8.0.2", + "contentHash": "nroMDjS7hNBPtkZqVBbSiQaQjWRDxITI8Y7XnDs97rqG3EbzVTNLZQf7bIeUJcaHOV8bca47s1Uxq94+2oGdxA==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.2" } }, "Microsoft.Extensions.Options": { @@ -382,11 +381,6 @@ "Microsoft.Kiota.Abstractions": "1.14.0" } }, - "Microsoft.NETCore.Platforms": { - "type": "Transitive", - "resolved": "7.0.4", - "contentHash": "yLEHlNN7O5WiND89r42sepgVwy5W/ZoTiFEdJDV7MHR1lW02LL7Nipz2TD5qM/Kx9W3/k3NP+PAP2qUdOm+leg==" - }, "Microsoft.TestPlatform.ObjectModel": { "type": "Transitive", "resolved": "17.11.0", @@ -421,12 +415,10 @@ }, "SvRooij.ContentPrep": { "type": "Transitive", - "resolved": "0.1.3-alpha0001", - "contentHash": "9exebiAiEz1cn5XKxivypRmpG0t0ykSFrenU8GtwYzv3JrIlkXT6WdntsVYr181ebWhdAWOU4cjR5IgMjDqQMg==", + "resolved": "0.2.2", + "contentHash": "U76+iUs+6ITR/kXNW5ylZj87yQ4UPmqUOConek8Tus16/lfwLNbItGPed8P/wbj/+517FU0pGyFUQiedY4mSfA==", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "7.0.1", - "Microsoft.NETCore.Platforms": "7.0.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" + "Microsoft.Extensions.Logging.Abstractions": "8.0.0" } }, "System.ClientModel": { @@ -440,8 +432,11 @@ }, "System.Diagnostics.DiagnosticSource": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "c9xLpVz6PL9lp/djOWtk5KPDZq3cSYpmXoJQY524EOtuFl5z9ZtsotpsyrDW40U1DRnQSYvcPKEUV0X//u6gkQ==" + "resolved": "6.0.1", + "contentHash": "KiLYDu2k2J82Q9BJpWiuQqCkFjRBWVq4jDzKKWawVi9KWzyD0XG3cmfX0vqTQlL14Wi9EufJrbL0+KCLTbqWiQ==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "6.0.0" + } }, "System.Diagnostics.EventLog": { "type": "Transitive", @@ -551,7 +546,7 @@ "winget.communityrepository": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.2, )", "YamlDotNet": "[16.0.0, )" } }, @@ -561,15 +556,15 @@ "Azure.Core": "[1.44.1, )", "Microsoft.Bcl.AsyncInterfaces": "[8.0.0, )", "Microsoft.CSharp": "[4.7.0, )", - "Microsoft.Extensions.Http": "[8.0.0, )", - "Microsoft.Extensions.Logging.Abstractions": "[8.0.1, )", + "Microsoft.Extensions.Http": "[8.0.1, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.2, )", "Microsoft.Extensions.Options": "[8.0.2, )", "Microsoft.Graph.Beta": "[5.78.0-preview, )", "Microsoft.Graph.Core": "[3.2.0, )", "Microsoft.Identity.Client.Broker": "[4.66.2, )", "Microsoft.Identity.Client.Extensions.Msal": "[4.66.2, )", "Riok.Mapperly": "[3.6.0, )", - "SvRooij.ContentPrep": "[0.1.3-alpha0001, )", + "SvRooij.ContentPrep": "[0.2.2, )", "System.IdentityModel.Tokens.Jwt": "[8.0.2, )", "WinTuner.Proxy.Client": "[1.0.0, )", "Winget.CommunityRepository": "[1.0.0, )" @@ -578,7 +573,7 @@ "wintuner.proxy.client": { "type": "Project", "dependencies": { - "Microsoft.Extensions.Http": "[8.0.0, )", + "Microsoft.Extensions.Http": "[8.0.1, )", "Microsoft.Kiota.Abstractions": "[1.14.0, )", "Microsoft.Kiota.Http.HttpClientLibrary": "[1.14.0, )", "Microsoft.Kiota.Serialization.Json": "[1.14.0, )",