Skip to content
Open
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
1 change: 1 addition & 0 deletions doc/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ The following arguments are available:
| **-u, --urls** | Installer Url(s) used to extract relevant metadata for generating a manifest |
| **-v, --version** | Version to be used when updating the package version field. |
| **-d, --display-version** | Version to be used when updating the display version field. Version provided in the installer URL arguments will take precedence over this value. |
| **--display-name** | Name to be used when updating the display name field. |
| **--release-notes-url** | URL to be used when updating the release notes url field. |
| **--release-date** | Date to be used when updating the release date field. Expected format is "YYYY-MM-DD". |
| **-o, --out** | The output directory where the newly created manifests will be saved locally |
Expand Down
18 changes: 18 additions & 0 deletions src/WingetCreateCLI/Commands/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public static IEnumerable<Example> Examples
[Option('d', "display-version", Required = false, HelpText = "DisplayVersion_HelpText", ResourceType = typeof(Resources))]
public string DisplayVersion { get; set; }

/// <summary>
/// Gets or sets the new value used to update the display name field in the manifest.
/// </summary>
[Option("display-name", Required = false, HelpText = "DisplayName_HelpText", ResourceType = typeof(Resources))]
public string DisplayName { get; set; }

/// <summary>
/// Gets or sets the release notes URL for the manifest.
/// </summary>
Expand Down Expand Up @@ -367,6 +373,18 @@ public async Task<Manifests> UpdateManifestsAutonomously(Manifests manifests)
}
}

if (!string.IsNullOrEmpty(this.DisplayName))
{
// Use --display-name value if provided as an argument.
foreach (InstallerMetadata installerUpdate in installerMetadataList)
{
if (string.IsNullOrEmpty(installerUpdate.DisplayName))
{
installerUpdate.DisplayName = this.DisplayName;
}
}
}

var originalAppsAndFeaturesEntries = installerManifest.Installers
.Where(i => i.AppsAndFeaturesEntries != null)
.SelectMany(i => i.AppsAndFeaturesEntries);
Expand Down
9 changes: 9 additions & 0 deletions src/WingetCreateCLI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/WingetCreateCLI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,9 @@ Warning: Using this argument may result in the token being logged. Consider an a
<data name="UnchangedDisplayVersion_Warning" xml:space="preserve">
<value>Base manifest contains DisplayVersion that has not been updated. Use --display-version CLI arg or provide the version in the installer URL.</value>
</data>
<data name="DisplayName_HelpText" xml:space="preserve">
<value>Name to be used when updating the display name field.</value>
</data>
<data name="DisplayVersion_HelpText" xml:space="preserve">
<value>Version to be used when updating the display version field. Version provided in the installer URL arguments will take precedence over this value.</value>
</data>
Expand Down
19 changes: 19 additions & 0 deletions src/WingetCreateCore/Common/PackageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,25 @@ public static void UpdateInstallerNodesAsync(List<InstallerMetadata> installerMe
}
}

// Update DisplayName for each AppsAndFeaturesEntry
if (!string.IsNullOrEmpty(installerUpdate.DisplayName))
{
if (newInstaller.AppsAndFeaturesEntries != null)
{
newInstaller.AppsAndFeaturesEntries[0].DisplayName = installerUpdate.DisplayName;
}
else
{
newInstaller.AppsAndFeaturesEntries = new List<AppsAndFeaturesEntry>
{
new AppsAndFeaturesEntry
{
DisplayName = installerUpdate.DisplayName,
},
};
}
}

// if the installerUpdate does not have a binary or url architecture specified, then just use what is specified in the installer.
Installer existingInstallerMatch = FindInstallerMatch(
newInstaller,
Expand Down
5 changes: 5 additions & 0 deletions src/WingetCreateCore/Models/InstallerMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public class InstallerMetadata
/// </summary>
public Scope? OverrideScope { get; set; }

/// <summary>
/// Gets or sets the display name specified as a CLI arg.
/// </summary>
public string DisplayName { get; set; }

/// <summary>
/// Gets or sets the display version specified as a CLI arg or an installer url argument.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PackageIdentifier: TestPublisher.UpdateDisplayName
PackageVersion: 0.1.2
PackageName: Test for updating display name through CLI arg
Publisher: Test publisher
License: MIT
ShortDescription: A manifest used to test whether the display name is correctly updated with the CLI arg
InstallerLocale: en-US
Installers:
# DisplayVersion: 1.0.0
- Architecture: x64
InstallerUrl: https://fakedomain.com/WingetCreateTestExeInstaller.exe
InstallerType: exe
AppsAndFeaturesEntries:
- DisplayName: FooApp 1.0.0
InstallerSha256: A7803233EEDB6A4B59B3024CCF9292A6FFFB94507DC998AA67C5B745D197A5DC
# No DisplayVersion
- Architecture: arm64
InstallerUrl: https://fakedomain.com/WingetCreateTestExeInstaller.exe
InstallerType: exe
InstallerSha256: A7803233EEDB6A4B59B3024CCF9292A6FFFB94507DC998AA67C5B745D197A5DC
PackageLocale: en-US
ManifestType: singleton
ManifestVersion: 1.4.0
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,54 @@ public async Task UpdateWithAllUrlArguments()
ClassicAssert.AreNotEqual(initialSecondDisplayVersion, updatedSecondDisplayVersion, "DisplayVersion should be updated");
}

/// <summary>
/// Verifies that display name provided as CLI arg correctly updates the display name in the manifest.
/// </summary>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
[Test]
public async Task UpdateDisplayName()
{
TestUtils.InitializeMockDownload();
TestUtils.SetMockHttpResponseContent(TestConstants.TestExeInstaller);
string testInstallerUrl = $"https://fakedomain.com/{TestConstants.TestExeInstaller}";
string displayNameForCLIArg = "FooApp 2.3.4.5";

var initialManifestContent = TestUtils.GetInitialManifestContent("TestPublisher.UpdateDisplayName.yaml");
UpdateCommand command = new UpdateCommand
{
Id = "TestPublisher.UpdateDisplayName",
Version = "1.2.3.4",
InstallerUrls = new[]
{
$"{testInstallerUrl}|x64",
$"{testInstallerUrl}|arm64",
},
DisplayName = displayNameForCLIArg,
};
var initialManifests = Serialization.DeserializeManifestContents(initialManifestContent);
var updatedManifests = await RunUpdateCommand(command, initialManifestContent);
ClassicAssert.IsNotNull(updatedManifests, "Command should have succeeded.");

// Initial installers
var initialFirstInstaller = initialManifests.SingletonManifest.Installers[0];

// Initial display names (second installer does not have a display name)
var initialFirstDisplayName = initialFirstInstaller.AppsAndFeaturesEntries.FirstOrDefault().DisplayName;

// Updated installers
var updatedFirstInstaller = updatedManifests.InstallerManifest.Installers[0];
var updatedSecondInstaller = updatedManifests.InstallerManifest.Installers[1];

// Updated display names (second installer does not have a display name)
var updatedFirstDisplayName = updatedFirstInstaller.AppsAndFeaturesEntries.FirstOrDefault().DisplayName;

ClassicAssert.AreEqual(displayNameForCLIArg, updatedFirstDisplayName, "DisplayName should be updated by the value in the CLI arg");
ClassicAssert.IsNull(updatedSecondInstaller.AppsAndFeaturesEntries);

ClassicAssert.AreNotEqual(initialFirstInstaller.InstallerSha256, updatedFirstInstaller.InstallerSha256, "InstallerSha256 should be updated");
ClassicAssert.AreNotEqual(initialFirstDisplayName, updatedFirstDisplayName, "DisplayName should be updated");
}

/// <summary>
/// Verifies that display version provided as CLI arg and in the URL arguments correctly updates the display version in the manifest.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
<None Update="Resources\TestPublisher.SingleInstallerWithMultipleDisplayVersions.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\TestPublisher.UpdateDisplayName.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\TestPublisher.UpdateDisplayVersion.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down