diff --git a/doc/update.md b/doc/update.md index 43599f2a..075840cd 100644 --- a/doc/update.md +++ b/doc/update.md @@ -39,30 +39,27 @@ e.g., The following additional arguments can be provided with the installer URL(s): #### Format + `'||...'` #### Override Architecture -`'|'` Winget-Create will attempt to determine the architecture of the installer package by performing a regex string match to identify the possible architecture in the installer url. If no match is found, Winget-Create will resort to obtaining the architecture from the downloaded installer. If Winget-Create fails to detect the architecture from the binary or the detected architecture does not match an architecture in the existing manifest, Winget-Create will fail to generate the manifest. In this case, you can explicitly provide the intended architecture and override the detected architecture using the following format: `'|'` #### Override Scope -`'|'` In case there are multiple installers with the same architecture, it may mean the same installer is available for multiple scopes. In this case, you can explicitly provide the installer scope in the update command using the following following argument format: `'|'` #### Display Version -`'|'` In some cases, the publisher of the package may use a different marketing version than the actual version written to Apps & Features. In this case, the manifest will contain `DisplayVersion` field. You can update the `DisplayVersion` field using the `--display-version` CLI arg if all installers use the same display version. If the display version differs for each installer, you can use following argument format: `'|'` - ## Usage Examples Search for an existing manifest and update the version: diff --git a/src/WingetCreateCLI/Commands/UpdateCommand.cs b/src/WingetCreateCLI/Commands/UpdateCommand.cs index 9ca3f039..46168e6c 100644 --- a/src/WingetCreateCLI/Commands/UpdateCommand.cs +++ b/src/WingetCreateCLI/Commands/UpdateCommand.cs @@ -825,18 +825,10 @@ private List ParseInstallerUrlsForArguments(List inst } // If value is not a convertible enum, it is assumed to be a display version. - else if (!string.IsNullOrEmpty(argumentString)) + else if (!string.IsNullOrEmpty(argumentString) && !displayVersionPresent) { - if (displayVersionPresent) - { - Logger.ErrorLocalized(nameof(Resources.MultipleDisplayVersion_Error)); - return null; - } - else - { - displayVersionPresent = true; - installerMetadata.DisplayVersion = argumentString; - } + displayVersionPresent = true; + installerMetadata.DisplayVersion = argumentString; } else { diff --git a/src/WingetCreateCLI/Properties/Resources.Designer.cs b/src/WingetCreateCLI/Properties/Resources.Designer.cs index 2b2aa126..4a4e0a5a 100644 --- a/src/WingetCreateCLI/Properties/Resources.Designer.cs +++ b/src/WingetCreateCLI/Properties/Resources.Designer.cs @@ -1851,15 +1851,6 @@ public static string MultipleArchitectureOverride_Error { } } - /// - /// Looks up a localized string similar to Multiple display versions detected. Only one version can be specified in the installer URL.. - /// - public static string MultipleDisplayVersion_Error { - get { - return ResourceManager.GetString("MultipleDisplayVersion_Error", resourceCulture); - } - } - /// /// Looks up a localized string similar to Updating a manifest is only supported with the same number of installer URLs.. /// diff --git a/src/WingetCreateCLI/Properties/Resources.resx b/src/WingetCreateCLI/Properties/Resources.resx index d522dc44..dcb09166 100644 --- a/src/WingetCreateCLI/Properties/Resources.resx +++ b/src/WingetCreateCLI/Properties/Resources.resx @@ -1363,9 +1363,6 @@ Version to be used when updating the display version field. Version provided in the installer URL arguments will take precendence over this value. - - Multiple display versions detected. Only one version can be specified in the installer URL. - Using display version '{0}' for {1} {0} - will be replaced with the display version provided in the installer URL diff --git a/src/WingetCreateCore/Common/PackageParser.cs b/src/WingetCreateCore/Common/PackageParser.cs index ae396989..c56312ed 100644 --- a/src/WingetCreateCore/Common/PackageParser.cs +++ b/src/WingetCreateCore/Common/PackageParser.cs @@ -455,7 +455,8 @@ private static void UpdateInstallerMetadata(Installer existingInstaller, Install if (existingInstaller.AppsAndFeaturesEntries != null && newInstaller.AppsAndFeaturesEntries != null) { - // New installer will always have a single entry in AppsAndFeaturesEntries + // When --display-version is provided, AppsAndFeaturesEntries for the new installer will not be null + // and will contain a single entry. string newDisplayVersion = newInstaller.AppsAndFeaturesEntries.FirstOrDefault().DisplayVersion; // Set DisplayVersion for each new installer if it exists in the corresponding existing installer. diff --git a/src/WingetCreateCore/Models/InstallerMetadata.cs b/src/WingetCreateCore/Models/InstallerMetadata.cs index 8e187b75..e260b37c 100644 --- a/src/WingetCreateCore/Models/InstallerMetadata.cs +++ b/src/WingetCreateCore/Models/InstallerMetadata.cs @@ -47,7 +47,7 @@ public class InstallerMetadata public Scope? OverrideScope { get; set; } /// - /// Gets or sets the display version specified as a CLI arg or an installer argument. + /// Gets or sets the display version specified as a CLI arg or an installer url argument. /// public string DisplayVersion { get; set; } diff --git a/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs b/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs index 2cc2fd32..eca41fc6 100644 --- a/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs +++ b/src/WingetCreateTests/WingetCreateTests/UnitTests/UpdateCommandTests.cs @@ -390,12 +390,14 @@ public async Task UpdateFailsOverrideWithMultipleScopes() public async Task UpdateFailsWithMultipleDisplayVersions() { string installerUrl = $"https://fakedomain.com/{TestConstants.TestExeInstaller}"; + string displayVersion1 = "3.4"; + string displayVersion2 = "1.2"; (UpdateCommand badCommand, var manifests) = - GetUpdateCommandAndManifestData("TestPublisher.ScopeOverride", "1.2.3.4", this.tempPath, new[] { $"{installerUrl}|3.4|1.2" }); + GetUpdateCommandAndManifestData("TestPublisher.ScopeOverride", "1.2.3.4", this.tempPath, new[] { $"{installerUrl}|{displayVersion1}|{displayVersion2}" }); var failedUpdateManifests = await RunUpdateCommand(badCommand, manifests); ClassicAssert.IsNull(failedUpdateManifests, "Command should have failed due to multiple display versions specified for a single installer."); string result = this.sw.ToString(); - Assert.That(result, Does.Contain(Resources.MultipleDisplayVersion_Error), "Failed to show multiple display version error."); + Assert.That(result, Does.Contain(string.Format(Resources.UnableToParseArgument_Error, displayVersion2)), "Failed to show parsing error due to multiple string overrides."); } ///