Skip to content

Commit

Permalink
Combine Custom and Silient parameters 🕵️
Browse files Browse the repository at this point in the history
PR: #81 
Fixed #77
  • Loading branch information
svrooij authored Jun 13, 2024
1 parent e9d1aa8 commit 220d330
Show file tree
Hide file tree
Showing 16 changed files with 199 additions and 170 deletions.
8 changes: 7 additions & 1 deletion src/Svrooij.WinTuner.CmdLets/Commands/DeployWtWin32App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,17 @@ public class DeployWtWin32App : BaseIntuneCmdlet
/// <inheritdoc/>
public override async Task ProcessRecordAsync(CancellationToken cancellationToken)
{
logger?.LogDebug("Validating authentication parameters");
ValidateAuthenticationParameters();
logger?.LogDebug("Authentication parameters validated");

if (App is null)
{
if (ParameterSetName == ParameterSetWinGet)
{
logger?.LogDebug("Loading package details from RootPackageFolder {RootPackageFolder}, PackageId {PackageId}, Version {Version}", RootPackageFolder, PackageId, Version);
PackageFolder = Path.Combine(RootPackageFolder!, PackageId!, Version!);
logger?.LogDebug("Loading package details from folder {packageFolder}", PackageFolder);
}

if (PackageFolder is not null)
Expand All @@ -156,7 +160,9 @@ public override async Task ProcessRecordAsync(CancellationToken cancellationToke
}
else
{
throw new ArgumentException("No package or package id specified");
var ex = new ArgumentException("No App or PackageFolder was provided");
logger?.LogError(ex, "No App or PackageFolder was provided");
throw ex;
}
}

Expand Down
14 changes: 13 additions & 1 deletion src/Svrooij.WinTuner.CmdLets/Commands/NewWtWingetPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ public class NewWtWingetPackage : DependencyCmdlet<Startup>
HelpMessage = "Package WinGet script, instead of the actual installer. Helpful for installers that don't really work with WinTuner.")]
public bool? PackageScript { get; set; }

/// <summary>
/// Desired locale
/// </summary>
[Parameter(
Mandatory = false,
Position = 7,
ValueFromPipeline = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The desired locale, if available (eg. 'en-US')")]
public string? Locale { get; set; }

[ServiceDependency]
private ILogger<NewWtWingetPackage> logger;

Expand Down Expand Up @@ -139,7 +150,8 @@ public override async Task ProcessRecordAsync(CancellationToken cancellationToke
{
Architecture = Architecture,
InstallerContext = InstallerContext,
PackageScript = PackageScript ?? false
PackageScript = PackageScript ?? false,
Locale = Locale,
},
cancellationToken: cancellationToken);

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.11.3" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Svrooij.PowerShell.DependencyInjection" Version="1.1.4" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.19">
<PrivateAssets>All</PrivateAssets>
Expand Down
62 changes: 31 additions & 31 deletions src/Svrooij.WinTuner.CmdLets/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"net6.0": {
"Azure.Identity": {
"type": "Direct",
"requested": "[1.11.3, )",
"resolved": "1.11.3",
"contentHash": "4EsGMAr+oog5UqHs46qwA7S/lJiwpXjPBY3t9tQBmJ8nsgmT/LLnrc32eiTlfOdfKxUz4fxBD2YjSnVZacu97w==",
"requested": "[1.11.4, )",
"resolved": "1.11.4",
"contentHash": "Sf4BoE6Q3jTgFkgBkx7qztYOFELBCo+wQgpYDwal/qJ1unBH73ywPztIJKXBXORRzAeNijsuxhk94h0TIMvfYg==",
"dependencies": {
"Azure.Core": "1.38.0",
"Microsoft.Identity.Client": "4.60.3",
"Microsoft.Identity.Client.Extensions.Msal": "4.60.3",
"Microsoft.Identity.Client": "4.61.3",
"Microsoft.Identity.Client.Extensions.Msal": "4.61.3",
"System.Memory": "4.5.4",
"System.Security.Cryptography.ProtectedData": "4.7.0",
"System.Text.Json": "4.7.2",
Expand Down Expand Up @@ -267,28 +267,28 @@
},
"Microsoft.Identity.Client": {
"type": "Transitive",
"resolved": "4.61.1",
"contentHash": "lhOpbxaaVfAJ2pocXHxSpYbO5JhVznQLMX7s4CCP0Ay0Xozk8YyIwVScbnCPotEaG2EnQrH+44qymrCLte9juw==",
"resolved": "4.61.3",
"contentHash": "naJo/Qm35Caaoxp5utcw+R8eU8ZtLz2ALh8S+gkekOYQ1oazfCQMWVT4NJ/FnHzdIJlm8dMz0oMpMGCabx5odA==",
"dependencies": {
"Microsoft.IdentityModel.Abstractions": "6.35.0",
"System.Diagnostics.DiagnosticSource": "6.0.1"
}
},
"Microsoft.Identity.Client.Broker": {
"type": "Transitive",
"resolved": "4.61.1",
"contentHash": "YTxDfFSgWxrtcqL8cee+LmyFRgPbQZ3wQP6z0POCr0ZgNDjKUsxYHk/iK1Iegz3t6BUnEdnMWSdQ0ZhcG7NZHQ==",
"resolved": "4.61.3",
"contentHash": "VX8YJYmjNZzWjLuwAwBWzTtfNRTqjj5DKPEci6eNa2tedBWSyOGvcsVMVUL/vy1oRSAjfpwzUIFlXCmhWnCAeA==",
"dependencies": {
"Microsoft.Identity.Client": "4.61.1",
"Microsoft.Identity.Client": "4.61.3",
"Microsoft.Identity.Client.NativeInterop": "0.16.1"
}
},
"Microsoft.Identity.Client.Extensions.Msal": {
"type": "Transitive",
"resolved": "4.61.1",
"contentHash": "aTDwdyurRz89EeTW9PFtF3pke7WTgKyaqGjeuZ0x7aSsWbupb14dXM/POKYO0D7bfpx7utyJ2A2axmb3T2zfSg==",
"resolved": "4.61.3",
"contentHash": "PWnJcznrSGr25MN8ajlc2XIDW4zCFu0U6FkpaNLEWLgd1NgFCp5uDY3mqLDgM8zCN8hqj8yo5wHYfLB2HjcdGw==",
"dependencies": {
"Microsoft.Identity.Client": "4.61.1",
"Microsoft.Identity.Client": "4.61.3",
"System.Security.Cryptography.ProtectedData": "4.5.0"
}
},
Expand All @@ -299,23 +299,23 @@
},
"Microsoft.IdentityModel.Abstractions": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "xXFP4PUcI/l4n3hpw4TXbvONNTQ9WflyMxUx03qNJXSd7dVtxbFrL+B9+IevMwzvktZjTVfMdDlzQoTzdtN1bA=="
"resolved": "7.6.0",
"contentHash": "q4MZ8d0LlWKWtQfxNl9ZRZVOQ7IPEAR6CF4rFKITfuqEUOhqrbwHbqBanReI37155IKb8V/tPJqpPa3KXm9wQQ=="
},
"Microsoft.IdentityModel.JsonWebTokens": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "gH3c88+YdT5QI6Rw2nnwjDUxzLgPPPbjMvUwvJrITyNAV3L5aswqxKIlmyQhaqltjGBGrMsCZCKwampWEMDN2w==",
"resolved": "7.6.0",
"contentHash": "lsleZbCuh3wZ3RfKd8WJ7E52nIeQQzJsDrgHN+B3Zhzd32UTQ1V3Vjn1N9PssnSulAoEMF0aAiue7ucX+TPoQA==",
"dependencies": {
"Microsoft.IdentityModel.Tokens": "7.5.2"
"Microsoft.IdentityModel.Tokens": "7.6.0"
}
},
"Microsoft.IdentityModel.Logging": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "FpMJ2i1e8Z+1rAchYQiawk0ChwYv6CNtCQDtMzwzkZtUWQYmkrkLXzl3qniOT8FFQck7bPKhQJY6nU7P7tojwQ==",
"resolved": "7.6.0",
"contentHash": "7AVJhNY4y/i96XGfaXovX8aAyYWz6HHtPEPHPpbg5JCchwVaoO08VmmpHe0L2gVagW/iHG0w4a4Xg9gxLXQ/8A==",
"dependencies": {
"Microsoft.IdentityModel.Abstractions": "7.5.2"
"Microsoft.IdentityModel.Abstractions": "7.6.0"
}
},
"Microsoft.IdentityModel.Protocols": {
Expand All @@ -338,10 +338,10 @@
},
"Microsoft.IdentityModel.Tokens": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "VFLS4Ajy5jadM/YV9x3FA4pHHwbEWTjkbN/RtShqVH8eI8j6UDg5522ogTx1iMLJKQdL9QbfxXx4d1+w1eCDgQ==",
"resolved": "7.6.0",
"contentHash": "xvEil42RUe4Si/TuLDvglNXpklgCWMSecPduczXPS2BAypjheUehPqKLwIy8vSdzB4K2zza3yLgmODBt+J6ZxQ==",
"dependencies": {
"Microsoft.IdentityModel.Logging": "7.5.2"
"Microsoft.IdentityModel.Logging": "7.6.0"
}
},
"Microsoft.Kiota.Abstractions": {
Expand Down Expand Up @@ -860,11 +860,11 @@
},
"System.IdentityModel.Tokens.Jwt": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "taMjs3z9+tTYNhdD5g5XU89gMcqX7PSI6oji7yZXK8E4T1XjsZR5yDLdIqC1PVKYL5FAlrNWBNBaLshuESYHlw==",
"resolved": "7.6.0",
"contentHash": "LIuEbv/kFpuw00yI/mPu+T9NAVdH/u7Y5ChCGzYQQeCg9Pft2C7HFWuO/P+Z7c2RcySNjVk1FmuAheKjYIbOkw==",
"dependencies": {
"Microsoft.IdentityModel.JsonWebTokens": "7.5.2",
"Microsoft.IdentityModel.Tokens": "7.5.2"
"Microsoft.IdentityModel.JsonWebTokens": "7.6.0",
"Microsoft.IdentityModel.Tokens": "7.6.0"
}
},
"System.IO": {
Expand Down Expand Up @@ -1258,11 +1258,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.61.1, )",
"Microsoft.Identity.Client.Extensions.Msal": "[4.61.1, )",
"Microsoft.Identity.Client.Broker": "[4.61.3, )",
"Microsoft.Identity.Client.Extensions.Msal": "[4.61.3, )",
"Riok.Mapperly": "[3.5.1, )",
"SvRooij.ContentPrep": "[0.1.3-alpha0001, )",
"System.IdentityModel.Tokens.Jwt": "[7.5.2, )",
"System.IdentityModel.Tokens.Jwt": "[7.6.0, )",
"Winget.CommunityRepository": "[1.0.0, )"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public override string ToString()

public string? GetPreferred()
{
return Custom ?? Silent ?? SilentWithProgress; // ?? Interactive;
var result = string.Join(' ', Custom, (Silent ?? SilentWithProgress)).Trim();
return string.IsNullOrEmpty(result) ? null : result; // ?? Interactive
}
}

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.11.3" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<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
62 changes: 31 additions & 31 deletions src/WingetIntune.Cli/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.11.3, )",
"resolved": "1.11.3",
"contentHash": "4EsGMAr+oog5UqHs46qwA7S/lJiwpXjPBY3t9tQBmJ8nsgmT/LLnrc32eiTlfOdfKxUz4fxBD2YjSnVZacu97w==",
"requested": "[1.11.4, )",
"resolved": "1.11.4",
"contentHash": "Sf4BoE6Q3jTgFkgBkx7qztYOFELBCo+wQgpYDwal/qJ1unBH73ywPztIJKXBXORRzAeNijsuxhk94h0TIMvfYg==",
"dependencies": {
"Azure.Core": "1.38.0",
"Microsoft.Identity.Client": "4.60.3",
"Microsoft.Identity.Client.Extensions.Msal": "4.60.3",
"Microsoft.Identity.Client": "4.61.3",
"Microsoft.Identity.Client.Extensions.Msal": "4.61.3",
"System.Memory": "4.5.4",
"System.Security.Cryptography.ProtectedData": "4.7.0",
"System.Text.Json": "4.7.2",
Expand Down Expand Up @@ -472,28 +472,28 @@
},
"Microsoft.Identity.Client": {
"type": "Transitive",
"resolved": "4.61.1",
"contentHash": "lhOpbxaaVfAJ2pocXHxSpYbO5JhVznQLMX7s4CCP0Ay0Xozk8YyIwVScbnCPotEaG2EnQrH+44qymrCLte9juw==",
"resolved": "4.61.3",
"contentHash": "naJo/Qm35Caaoxp5utcw+R8eU8ZtLz2ALh8S+gkekOYQ1oazfCQMWVT4NJ/FnHzdIJlm8dMz0oMpMGCabx5odA==",
"dependencies": {
"Microsoft.IdentityModel.Abstractions": "6.35.0",
"System.Diagnostics.DiagnosticSource": "6.0.1"
}
},
"Microsoft.Identity.Client.Broker": {
"type": "Transitive",
"resolved": "4.61.1",
"contentHash": "YTxDfFSgWxrtcqL8cee+LmyFRgPbQZ3wQP6z0POCr0ZgNDjKUsxYHk/iK1Iegz3t6BUnEdnMWSdQ0ZhcG7NZHQ==",
"resolved": "4.61.3",
"contentHash": "VX8YJYmjNZzWjLuwAwBWzTtfNRTqjj5DKPEci6eNa2tedBWSyOGvcsVMVUL/vy1oRSAjfpwzUIFlXCmhWnCAeA==",
"dependencies": {
"Microsoft.Identity.Client": "4.61.1",
"Microsoft.Identity.Client": "4.61.3",
"Microsoft.Identity.Client.NativeInterop": "0.16.1"
}
},
"Microsoft.Identity.Client.Extensions.Msal": {
"type": "Transitive",
"resolved": "4.61.1",
"contentHash": "aTDwdyurRz89EeTW9PFtF3pke7WTgKyaqGjeuZ0x7aSsWbupb14dXM/POKYO0D7bfpx7utyJ2A2axmb3T2zfSg==",
"resolved": "4.61.3",
"contentHash": "PWnJcznrSGr25MN8ajlc2XIDW4zCFu0U6FkpaNLEWLgd1NgFCp5uDY3mqLDgM8zCN8hqj8yo5wHYfLB2HjcdGw==",
"dependencies": {
"Microsoft.Identity.Client": "4.61.1",
"Microsoft.Identity.Client": "4.61.3",
"System.Security.Cryptography.ProtectedData": "4.5.0"
}
},
Expand All @@ -504,23 +504,23 @@
},
"Microsoft.IdentityModel.Abstractions": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "xXFP4PUcI/l4n3hpw4TXbvONNTQ9WflyMxUx03qNJXSd7dVtxbFrL+B9+IevMwzvktZjTVfMdDlzQoTzdtN1bA=="
"resolved": "7.6.0",
"contentHash": "q4MZ8d0LlWKWtQfxNl9ZRZVOQ7IPEAR6CF4rFKITfuqEUOhqrbwHbqBanReI37155IKb8V/tPJqpPa3KXm9wQQ=="
},
"Microsoft.IdentityModel.JsonWebTokens": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "gH3c88+YdT5QI6Rw2nnwjDUxzLgPPPbjMvUwvJrITyNAV3L5aswqxKIlmyQhaqltjGBGrMsCZCKwampWEMDN2w==",
"resolved": "7.6.0",
"contentHash": "lsleZbCuh3wZ3RfKd8WJ7E52nIeQQzJsDrgHN+B3Zhzd32UTQ1V3Vjn1N9PssnSulAoEMF0aAiue7ucX+TPoQA==",
"dependencies": {
"Microsoft.IdentityModel.Tokens": "7.5.2"
"Microsoft.IdentityModel.Tokens": "7.6.0"
}
},
"Microsoft.IdentityModel.Logging": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "FpMJ2i1e8Z+1rAchYQiawk0ChwYv6CNtCQDtMzwzkZtUWQYmkrkLXzl3qniOT8FFQck7bPKhQJY6nU7P7tojwQ==",
"resolved": "7.6.0",
"contentHash": "7AVJhNY4y/i96XGfaXovX8aAyYWz6HHtPEPHPpbg5JCchwVaoO08VmmpHe0L2gVagW/iHG0w4a4Xg9gxLXQ/8A==",
"dependencies": {
"Microsoft.IdentityModel.Abstractions": "7.5.2"
"Microsoft.IdentityModel.Abstractions": "7.6.0"
}
},
"Microsoft.IdentityModel.Protocols": {
Expand All @@ -543,10 +543,10 @@
},
"Microsoft.IdentityModel.Tokens": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "VFLS4Ajy5jadM/YV9x3FA4pHHwbEWTjkbN/RtShqVH8eI8j6UDg5522ogTx1iMLJKQdL9QbfxXx4d1+w1eCDgQ==",
"resolved": "7.6.0",
"contentHash": "xvEil42RUe4Si/TuLDvglNXpklgCWMSecPduczXPS2BAypjheUehPqKLwIy8vSdzB4K2zza3yLgmODBt+J6ZxQ==",
"dependencies": {
"Microsoft.IdentityModel.Logging": "7.5.2"
"Microsoft.IdentityModel.Logging": "7.6.0"
}
},
"Microsoft.Kiota.Abstractions": {
Expand Down Expand Up @@ -728,11 +728,11 @@
},
"System.IdentityModel.Tokens.Jwt": {
"type": "Transitive",
"resolved": "7.5.2",
"contentHash": "taMjs3z9+tTYNhdD5g5XU89gMcqX7PSI6oji7yZXK8E4T1XjsZR5yDLdIqC1PVKYL5FAlrNWBNBaLshuESYHlw==",
"resolved": "7.6.0",
"contentHash": "LIuEbv/kFpuw00yI/mPu+T9NAVdH/u7Y5ChCGzYQQeCg9Pft2C7HFWuO/P+Z7c2RcySNjVk1FmuAheKjYIbOkw==",
"dependencies": {
"Microsoft.IdentityModel.JsonWebTokens": "7.5.2",
"Microsoft.IdentityModel.Tokens": "7.5.2"
"Microsoft.IdentityModel.JsonWebTokens": "7.6.0",
"Microsoft.IdentityModel.Tokens": "7.6.0"
}
},
"System.IO": {
Expand Down Expand Up @@ -919,11 +919,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.61.1, )",
"Microsoft.Identity.Client.Extensions.Msal": "[4.61.1, )",
"Microsoft.Identity.Client.Broker": "[4.61.3, )",
"Microsoft.Identity.Client.Extensions.Msal": "[4.61.3, )",
"Riok.Mapperly": "[3.5.1, )",
"SvRooij.ContentPrep": "[0.1.3-alpha0001, )",
"System.IdentityModel.Tokens.Jwt": "[7.5.2, )",
"System.IdentityModel.Tokens.Jwt": "[7.6.0, )",
"Winget.CommunityRepository": "[1.0.0, )"
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/WingetIntune/Intune/IntuneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,10 @@ private void LoadMsiDetails(string installerPath, ref PackageInfo packageInfo)

private void ComputeInstallerDetails(ref PackageInfo package, PackageOptions packageOptions)
{
var installer = package.GetBestFit(packageOptions.Architecture, packageOptions.InstallerContext)
?? package.GetBestFit(Architecture.Neutral, InstallerContext.Unknown)
?? package.GetBestFit(Architecture.Neutral, packageOptions.InstallerContext)
?? package.GetBestFit(packageOptions.Architecture, InstallerContext.Unknown);
var installer = package.GetBestFit(packageOptions.Architecture, packageOptions.InstallerContext, packageOptions.Locale)
?? package.GetBestFit(Architecture.Neutral, InstallerContext.Unknown, packageOptions.Locale)
?? package.GetBestFit(Architecture.Neutral, packageOptions.InstallerContext, packageOptions.Locale)
?? package.GetBestFit(packageOptions.Architecture, InstallerContext.Unknown, packageOptions.Locale);
if (installer == null && packageOptions.Architecture == Architecture.X64)
{
installer = package.GetBestFit(Architecture.X86, packageOptions.InstallerContext)
Expand Down
14 changes: 12 additions & 2 deletions src/WingetIntune/Intune/MetadataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,29 @@ public MetadataManager(ILogger<MetadataManager> logger, IFileManager fileManager

public async Task<PackageInfo> LoadPackageInfoFromFolderAsync(string folder, CancellationToken cancellationToken)
{
logger.LogDebug("Loading package info from {folder}", folder);
#if NET8_0_OR_GREATER
ArgumentException.ThrowIfNullOrEmpty(folder);
#endif
var filename = Path.Combine(folder, "app.json");
if (!fileManager.FileExists(filename))
{
throw new FileNotFoundException($"Could not find app.json in folder {folder}", filename);
var ex = new FileNotFoundException($"Could not find app.json in folder {folder}", filename);
logger.LogWarning(ex, "Could not find app.json in folder {folder}", folder);
throw ex;
}

logger.LogDebug("Loading package info from {filename}", filename);

var data = await fileManager.ReadAllBytesAsync(filename, cancellationToken);
return JsonSerializer.Deserialize<PackageInfo>(data, MyJsonContext.Default.PackageInfo)!;
var result = JsonSerializer.Deserialize<PackageInfo>(data, MyJsonContext.Default.PackageInfo);
if (result == null)
{
var ex = new InvalidOperationException($"Could not deserialize app.json");
logger.LogWarning(ex, "Could not deserialize app.json in folder {folder}", folder);
throw ex;
}
return result;
}

public Task<PackageInfo> LoadPackageInfoFromFolderAsync(string rootFolder, string packageId, string version, CancellationToken cancellationToken) =>
Expand Down
Loading

0 comments on commit 220d330

Please sign in to comment.