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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageVersion Include="Microsoft.Msix.Utils" Version="2.1.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.213" />
<PackageVersion Include="Microsoft.WindowsPackageManager.Utils" Version="1.12.350" />
<PackageVersion Include="Microsoft.WindowsPackageManager.Utils" Version="1.29.380" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Newtonsoft.Json.Schema" Version="3.0.15" />
Expand Down
2 changes: 1 addition & 1 deletion src/WingetCreateCLI/Commands/BaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace Microsoft.WingetCreateCLI.Commands
using System.Threading.Tasks;
using Microsoft.WingetCreateCLI.Logging;
using Microsoft.WingetCreateCLI.Models.Settings;
using Microsoft.WingetCreateCLI.Properties;
using Microsoft.WingetCreateCLI.Telemetry;
using Microsoft.WingetCreateCLI.Telemetry.Events;
using Microsoft.WingetCreateCore;
Expand All @@ -30,6 +29,7 @@ namespace Microsoft.WingetCreateCLI.Commands
using Octokit;
using RestSharp;
using Sharprompt;
using Resources = Microsoft.WingetCreateCLI.Properties.Resources;

/// <summary>
/// Abstract base command class that all commands inherit from.
Expand Down
2 changes: 1 addition & 1 deletion src/WingetCreateCLI/Commands/NewCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace Microsoft.WingetCreateCLI.Commands
using CommandLine.Text;
using Microsoft.WingetCreateCLI.Logging;
using Microsoft.WingetCreateCLI.Models.Settings;
using Microsoft.WingetCreateCLI.Properties;
using Microsoft.WingetCreateCLI.Telemetry;
using Microsoft.WingetCreateCLI.Telemetry.Events;
using Microsoft.WingetCreateCore;
Expand All @@ -27,6 +26,7 @@ namespace Microsoft.WingetCreateCLI.Commands
using Microsoft.WingetCreateCore.Models.Version;
using Newtonsoft.Json.Schema.Generation;
using Sharprompt;
using Resources = Microsoft.WingetCreateCLI.Properties.Resources;

/// <summary>
/// Command to launch a wizard that prompt users for information to generate a new manifest.
Expand Down
2 changes: 1 addition & 1 deletion src/WingetCreateCLI/Commands/ShowCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ namespace Microsoft.WingetCreateCLI.Commands
using CommandLine.Text;
using Microsoft.WingetCreateCLI.Logging;
using Microsoft.WingetCreateCLI.Models.Settings;
using Microsoft.WingetCreateCLI.Properties;
using Microsoft.WingetCreateCLI.Telemetry;
using Microsoft.WingetCreateCLI.Telemetry.Events;
using Microsoft.WingetCreateCore;
using Microsoft.WingetCreateCore.Models;
using Microsoft.WingetCreateCore.Models.Installer;
using Microsoft.WingetCreateCore.Models.Singleton;
using Microsoft.WingetCreateCore.Models.Version;
using Resources = Microsoft.WingetCreateCLI.Properties.Resources;

/// <summary>
/// Show command to display manifest from the packages repository.
Expand Down
2 changes: 1 addition & 1 deletion src/WingetCreateCLI/Commands/SubmitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ namespace Microsoft.WingetCreateCLI.Commands
using CommandLine.Text;
using Microsoft.VisualBasic;
using Microsoft.WingetCreateCLI.Logging;
using Microsoft.WingetCreateCLI.Properties;
using Microsoft.WingetCreateCLI.Telemetry;
using Microsoft.WingetCreateCLI.Telemetry.Events;
using Microsoft.WingetCreateCore;
using Microsoft.WingetCreateCore.Models;
using Microsoft.WingetCreateCore.Models.Singleton;
using Resources = Microsoft.WingetCreateCLI.Properties.Resources;

/// <summary>
/// Command to validate and submit a manifest to the GitHub Windows Package Manager repository.
Expand Down
8 changes: 7 additions & 1 deletion src/WingetCreateCLI/Commands/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace Microsoft.WingetCreateCLI.Commands
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.WingetCreateCLI.Logging;
using Microsoft.WingetCreateCLI.Models.Settings;
using Microsoft.WingetCreateCLI.Properties;
using Microsoft.WingetCreateCLI.Telemetry;
using Microsoft.WingetCreateCLI.Telemetry.Events;
using Microsoft.WingetCreateCore;
Expand All @@ -27,6 +26,7 @@ namespace Microsoft.WingetCreateCLI.Commands
using Microsoft.WingetCreateCore.Models.Locale;
using Microsoft.WingetCreateCore.Models.Version;
using Sharprompt;
using Resources = Microsoft.WingetCreateCLI.Properties.Resources;

/// <summary>
/// Command for updating the elements of an existing or local manifest.
Expand Down Expand Up @@ -640,6 +640,12 @@ private static Manifests ConvertSingletonToMultifileManifest(WingetCreateCore.Mo
cfg.CreateMap<WingetCreateCore.Models.Singleton.InstallationMetadata, WingetCreateCore.Models.Installer.InstallationMetadata>();
cfg.CreateMap<WingetCreateCore.Models.Singleton.Icon, WingetCreateCore.Models.DefaultLocale.Icon>();
cfg.CreateMap<WingetCreateCore.Models.Singleton.Authentication, WingetCreateCore.Models.Installer.Authentication>();
cfg.CreateMap<WingetCreateCore.Models.Singleton.MicrosoftEntraIdAuthenticationInfo, WingetCreateCore.Models.Installer.MicrosoftEntraIdAuthenticationInfo>();
cfg.CreateMap<WingetCreateCore.Models.Singleton.DesiredStateConfiguration, WingetCreateCore.Models.Installer.DesiredStateConfiguration>();
cfg.CreateMap<WingetCreateCore.Models.Singleton.PowerShell, WingetCreateCore.Models.Installer.PowerShell>();
cfg.CreateMap<WingetCreateCore.Models.Singleton.DSCv3, WingetCreateCore.Models.Installer.DSCv3>();
cfg.CreateMap<WingetCreateCore.Models.Singleton.Resources, WingetCreateCore.Models.Installer.Resources>();
cfg.CreateMap<WingetCreateCore.Models.Singleton.Resources2, WingetCreateCore.Models.Installer.Resources2>();
},
NullLoggerFactory.Instance);
var mapper = config.CreateMapper();
Expand Down
79 changes: 43 additions & 36 deletions src/WingetCreateCLI/PromptHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace Microsoft.WingetCreateCLI
using System.Linq;
using System.Reflection;
using Microsoft.WingetCreateCLI.Logging;
using Microsoft.WingetCreateCLI.Properties;
using Microsoft.WingetCreateCore;
using Microsoft.WingetCreateCore.Common;
using Microsoft.WingetCreateCore.Models.DefaultLocale;
using Microsoft.WingetCreateCore.Models.Installer;
using Sharprompt;
using Resources = Microsoft.WingetCreateCLI.Properties.Resources;

/// <summary>
/// Provides functionality for prompting the user for input to obtain field values for a manifest.
Expand Down Expand Up @@ -490,7 +490,7 @@ private static List<string> GenerateInstallerSelectionList(List<Installer> insta
var installerTuple = string.Join(" | ", new[]
{
installer.Architecture.ToEnumAttributeValue(),
installer.InstallerType.ToEnumAttributeValue(),
Comment thread
AmelBawa-msft marked this conversation as resolved.
Resolved
installer.InstallerType?.ToEnumAttributeValue(),
installer.Scope?.ToEnumAttributeValue(),
installer.InstallerLocale,
installer.InstallerUrl,
Expand All @@ -515,56 +515,63 @@ private static List<string> GenerateInstallerSelectionList(List<Installer> insta
private static void ApplyChangesToIndividualInstallers(Installer installerCopy, List<Installer> installers)
{
// Skip architecture as the default value when instantiated is x86.
var modifiedFields = installerCopy.GetType().GetProperties()
.Select(prop => prop)
.Where(pi =>
pi.GetValue(installerCopy) != null &&
pi.Name != nameof(Installer.Architecture) &&
pi.Name != nameof(Installer.AdditionalProperties));

foreach (var field in modifiedFields)
foreach (var property in typeof(Installer).GetProperties().Where(p =>
p.Name != nameof(Installer.Architecture) && p.Name != nameof(Installer.AdditionalProperties)))
{
foreach (Installer installer in installers)
var value = property.GetValue(installerCopy);
if (value != null)
{
var fieldValue = field.GetValue(installerCopy);
var prop = installer.GetType().GetProperty(field.Name);
if (prop.PropertyType.IsValueType)
foreach (var installer in installers)
{
prop.SetValue(installer, fieldValue);
property.SetValue(installer, ApplyPropertyChanges(value, property.GetValue(installer)));
}
else if (fieldValue is IList list)
}
}
}

private static object ApplyPropertyChanges(object value, object target)
{
var pending = new Queue<(object Source, object Target)>();
var result = CopyValue(value, target);
while (pending.Count > 0)
{
var (source, destination) = pending.Dequeue();
if (source is IList list)
{
foreach (var item in list)
{
prop.SetValue(installer, list.DeepClone());
((IList)destination).Add(CopyValue(item, null));
}
else if (fieldValue is Dependencies dependencies)
}
else
{
foreach (var property in source.GetType().GetProperties().Where(p => p.CanWrite && p.Name != nameof(Installer.AdditionalProperties)))
{
ApplyDependencyChangesToInstaller(dependencies, installer);
var propertyValue = property.GetValue(source);
if (propertyValue != null)
{
property.SetValue(destination, CopyValue(propertyValue, property.GetValue(destination)));
}
}
}
}
}

/// <summary>
/// Clones any non-null property values of the dependencies object and assigns them to the provided installer object.
/// </summary>
/// <param name="dependencies">Dependencies object with new values.</param>
/// <param name="installer">Installer object to assign new changes to.</param>
private static void ApplyDependencyChangesToInstaller(Dependencies dependencies, Installer installer)
{
var modifiedFields = dependencies.GetType().GetProperties()
.Select(prop => prop)
.Where(pi => pi.GetValue(dependencies) != null);
return result;

foreach (var field in modifiedFields.Where(f => f.Name != nameof(Installer.AdditionalProperties)))
object CopyValue(object source, object destination)
{
var fieldValue = field.GetValue(dependencies);
installer.Dependencies ??= new Dependencies();
var prop = installer.Dependencies.GetType().GetProperty(field.Name);
if (source == null || source.GetType().IsValueType || source is string)
{
return source;
}

if (fieldValue is IList list)
if (source is IList || destination == null)
{
prop.SetValue(installer.Dependencies, list.DeepClone());
destination = Activator.CreateInstance(source.GetType());
}

pending.Enqueue((source, destination));
return destination;
}
}

Expand Down
21 changes: 21 additions & 0 deletions src/WingetCreateCLI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1486,4 +1486,25 @@ Warning: Using this argument may result in the token being logged. Consider an a
<data name="MixedInstallerRootTypes_ErrorMessage" xml:space="preserve">
<value>Found mixed font and non-font installer types in the manifest. This is not a supported configuration and the manifest should be edited to contain only font or non-font installers before submission.</value>
</data>
<data name="DesiredStateConfiguration_KeywordDescription" xml:space="preserve">
<value>Desired state configuration (DSC) resources related to the package</value>
</data>
<data name="PowerShell_KeywordDescription" xml:space="preserve">
<value>DSC resources contained in PowerShell modules</value>
</data>
<data name="RepositoryUrl_KeywordDescription" xml:space="preserve">
<value>The URL of the repository containing the PowerShell module</value>
</data>
<data name="ModuleName_KeywordDescription" xml:space="preserve">
<value>The name of the PowerShell module containing DSC resources</value>
</data>
<data name="Resources_KeywordDescription" xml:space="preserve">
<value>The DSC resources contained in the module or package</value>
</data>
<data name="DSCv3_KeywordDescription" xml:space="preserve">
<value>DSC resources contained in the package using the DSC v3 specification</value>
</data>
<data name="Type_KeywordDescription" xml:space="preserve">
<value>The fully qualified type of the DSC resource</value>
</data>
</root>
2 changes: 1 addition & 1 deletion src/WingetCreateCLI/WingetCreateCLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<AssemblyName>WingetCreateCLI</AssemblyName>
<RootNamespace>Microsoft.WingetCreateCLI</RootNamespace>
<Version>1.12</Version>
<Version>1.28</Version>
<Platforms>x64;x86</Platforms>
<RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
4 changes: 2 additions & 2 deletions src/WingetCreateCore/Models/DefaultLocaleManifestModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public System.Collections.Generic.IDictionary<string, object> AdditionalProperti
}

/// <summary>
/// A representation of a multiple-file manifest representing a default app metadata in the OWC. v1.12.0
/// A representation of a multiple-file manifest representing a default app metadata in the OWC. v1.28.0
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "11.0.0.0 (Newtonsoft.Json v13.0.0.0)")]
public partial class DefaultLocaleManifest
Expand Down Expand Up @@ -335,7 +335,7 @@ public partial class DefaultLocaleManifest
[Newtonsoft.Json.JsonProperty("ManifestVersion", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)]
[System.ComponentModel.DataAnnotations.RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){2}$")]
public string ManifestVersion { get; set; } = "1.12.0";
public string ManifestVersion { get; set; } = "1.28.0";



Expand Down
Loading
Loading