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
4 changes: 4 additions & 0 deletions doc/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## New Features

### Source priority

Source priority is now available without enabling an experimental feature. Use `winget source add --priority <value>` or `winget source edit --name <source> --priority <value>` to configure it. Higher values take precedence; sources with equal priority still require disambiguation when multiple matches remain.

### Output locale override

Added a persistent `output.locale` setting to override winget interface language using a BCP47 tag.
Expand Down
12 changes: 0 additions & 12 deletions doc/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,3 @@ This feature enables support for fonts via `winget settings`. The `winget font l
"fonts": true
},
```

### sourcePriority

This feature enables sources to have a priority value assigned. Sources with a higher priority will appear earlier in search results and will be selected for installing new packages when multiple sources have a matching package.

Note that search result ordering is dependent on several factors, and source priority is the lowest field in that currently (match quality and field are more important).

```json
"experimentalFeatures": {
"sourcePriority": true
},
```
12 changes: 12 additions & 0 deletions doc/windows/package-manager/winget/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Source supports the following sub-commands for manipulating the sources.
| Sub-command | Description |
|--------------|-------------|
| **add** | Adds a new source. |
| **edit** | Edits an existing source. |
| **list** | Enumerates the list of enabled sources. |
| **update** | Updates a source. |
| **remove** | Removes a source. |
Expand All @@ -52,6 +53,7 @@ The **source** command supports the following options.
| **-n, --name** | The name to identify the source by. |
| **-a, --arg** | The URL or UNC of the source. |
| **-t, --type** | The type of source. |
| **-p, --priority** | Sets the source priority for **add** or **edit**. Higher values take precedence; new sources default to `0`. |
| **-?, --help** | Gets additional help on this command. |
| **--wait** | Prompts the user to press any key before exiting. |
| **--logs, --open-logs** | Open the default logs location. |
Expand All @@ -73,6 +75,16 @@ The **add** sub-command also supports the optional **type** parameter. The **typ
| **Microsoft.PreIndexed.Package** | The type of source \<default>. |
| **Microsoft.Rest** | A Microsoft REST API source. |

## Source priority

To prefer a source when installing packages, set its priority from an elevated terminal:

```powershell
winget source edit --name winget --priority 1
```

If multiple matches remain at the highest priority, refine the search or specify `--source`.

## list

the **list** sub-command enumerates the currently enabled sources. This sub-command also provides details on a specific source.
Expand Down
5 changes: 0 additions & 5 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,6 @@
"description": "Enable support for some commands to resume",
"type": "boolean",
"default": false
},
"sourcePriority": {
"description": "Enable source priority feature",
"type": "boolean",
"default": false
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ namespace AppInstaller::CLI
case Args::Type::SourceEditExplicit:
return Argument{ type, Resource::String::SourceEditExplicitArgumentDescription, ArgumentType::Standard };
case Args::Type::SourcePriority:
return Argument{ type, Resource::String::SourcePriorityArgumentDescription, ArgumentType::Standard, ExperimentalFeature::Feature::SourcePriority };
return Argument{ type, Resource::String::SourcePriorityArgumentDescription, ArgumentType::Standard };
case Args::Type::SourceTrustLevel:
return Argument{ type, Resource::String::SourceTrustLevelArgumentDescription, ArgumentType::Standard, Argument::Visibility::Help };
case Args::Type::ValidateManifest:
Expand Down
14 changes: 2 additions & 12 deletions src/AppInstallerCLICore/Commands/DscSourceResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "Resources.h"
#include "Workflows/SourceFlow.h"
#include <winget/RepositorySource.h>
#include <winget/ExperimentalFeature.h>

using namespace AppInstaller::Utility::literals;
using namespace AppInstaller::Repository;
Expand Down Expand Up @@ -111,10 +110,7 @@ namespace AppInstaller::CLI
Output.TrustLevel(TrustLevelStringFromFlags(source.TrustLevel));
Output.Explicit(source.Explicit);

if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::SourcePriority))
{
Output.Priority(source.Priority);
}
Output.Priority(source.Priority);

std::vector<Repository::SourceDetails> sources;
sources.emplace_back(source);
Expand Down Expand Up @@ -158,7 +154,6 @@ namespace AppInstaller::CLI
std::string priorityString;
if (Input.Priority())
{
THROW_HR_IF(APPINSTALLER_CLI_ERROR_EXPERIMENTAL_FEATURE_DISABLED, !Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::SourcePriority));
priorityString = std::to_string(Input.Priority().value());
SubContext->Args.AddArg(Execution::Args::Type::SourcePriority, priorityString);
}
Expand Down Expand Up @@ -202,7 +197,6 @@ namespace AppInstaller::CLI
std::string priorityString;
if (Input.Priority())
{
THROW_HR_IF(APPINSTALLER_CLI_ERROR_EXPERIMENTAL_FEATURE_DISABLED, !Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::SourcePriority));
priorityString = std::to_string(Input.Priority().value());
SubContext->Args.AddArg(Execution::Args::Type::SourcePriority, priorityString);
}
Expand Down Expand Up @@ -373,7 +367,6 @@ namespace AppInstaller::CLI
{
if (Input.Priority())
{
THROW_HR_IF(APPINSTALLER_CLI_ERROR_EXPERIMENTAL_FEATURE_DISABLED, !Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::SourcePriority));
if (Output.Priority())
{
return Input.Priority().value() == Output.Priority().value();
Expand Down Expand Up @@ -499,10 +492,7 @@ namespace AppInstaller::CLI
output.TrustLevel(TrustLevelStringFromFlags(source.TrustLevel));
output.Explicit(source.Explicit);

if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::SourcePriority))
{
output.Priority(source.Priority);
}
output.Priority(source.Priority);

WriteJsonOutputLine(context, output.ToJson());
}
Expand Down
10 changes: 2 additions & 8 deletions src/AppInstallerCLICore/Workflows/SourceFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ namespace AppInstaller::CLI::Workflow
table.OutputLine({ Resource::LocString(Resource::String::SourceListIdentifier), source.Identifier });
table.OutputLine({ Resource::LocString(Resource::String::SourceListTrustLevel), Repository::GetSourceTrustLevelForDisplay(source.TrustLevel)});
table.OutputLine({ Resource::LocString(Resource::String::SourceListExplicit), std::string{ Utility::ConvertBoolToString(source.Explicit) } });
if (ExperimentalFeature::IsEnabled(ExperimentalFeature::Feature::SourcePriority))
{
table.OutputLine({ Resource::LocString(Resource::String::SourceListPriority), std::to_string(source.Priority) });
}
table.OutputLine({ Resource::LocString(Resource::String::SourceListPriority), std::to_string(source.Priority) });

if (source.LastUpdateTime == Utility::ConvertUnixEpochToSystemClock(0))
{
Expand Down Expand Up @@ -410,10 +407,7 @@ namespace AppInstaller::CLI::Workflow
s.TrustLevel = std::vector<std::string>(sourceTrustLevels.begin(), sourceTrustLevels.end());
s.Explicit = source.Explicit;

if (ExperimentalFeature::IsEnabled(ExperimentalFeature::Feature::SourcePriority))
{
s.Priority = source.Priority;
}
s.Priority = source.Priority;

context.Reporter.Info() << s.ToJsonString() << std::endl;
}
Expand Down
3 changes: 1 addition & 2 deletions src/AppInstallerCLICore/Workflows/WorkflowBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,8 +1358,7 @@ namespace AppInstaller::CLI::Workflow
m_operationType == OperationType::Repair || m_operationType == OperationType::Export;

// Try limiting results to highest priority sources
if (searchResult.Matches.size() > 1 && !operationTargetsInstalled &&
ExperimentalFeature::IsEnabled(ExperimentalFeature::Feature::SourcePriority))
if (searchResult.Matches.size() > 1 && !operationTargetsInstalled)
{
// Find the set of matches that have the highest priority
std::vector<ResultMatch> highestPriorityMatches;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public void OneTimeTeardown()
public void Setup()
{
RemoveTestSource();
WinGetSettingsHelper.ConfigureFeature("sourcePriority", true);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ public static void InitializeAllFeatures(bool status)
ConfigureFeature(settingsJson, "resume", status);
ConfigureFeature(settingsJson, "reboot", status);
ConfigureFeature(settingsJson, "fonts", status);
ConfigureFeature(settingsJson, "sourcePriority", status);

SetWingetSettings(settingsJson);
}
Expand Down
9 changes: 0 additions & 9 deletions src/AppInstallerCLIE2ETests/InstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ namespace AppInstallerCLIE2ETests
/// </summary>
public class InstallCommand : BaseCommand
{
/// <summary>
/// One time set up.
/// </summary>
[OneTimeSetUp]
public void OneTimeSetup()
{
WinGetSettingsHelper.ConfigureFeature("sourcePriority", true);
}

/// <summary>
/// Set up.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLIE2ETests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Assuming you clone winget-cli in c:\dev, the localhost web server is running in
<Parameter name="LocalServerCertPath" value="C:\dev\Temp\servercert.cer" />
<Parameter name="InprocTestbedPath" value="c:\dev\winget-cli\src\x64\Debug\ComInprocTestbed\ComInprocTestbed.exe" />
<Parameter name="InprocTestbedUseTestPackage" value="false" />
<Parameter name="ForcedExperimentalFeatures" value="directMSI|resume|fonts|sourcePriority" />
<Parameter name="ForcedExperimentalFeatures" value="directMSI|resume|fonts" />
<Parameter name="SkipTestSource" value="false" />
</TestRunParameters>
</RunSettings>
Expand Down
9 changes: 0 additions & 9 deletions src/AppInstallerCLIE2ETests/SourceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ namespace AppInstallerCLIE2ETests
/// </summary>
public class SourceCommand : BaseCommand
{
/// <summary>
/// One time set up.
/// </summary>
[OneTimeSetUp]
public void OneTimeSetup()
{
WinGetSettingsHelper.ConfigureFeature("sourcePriority", true);
}

/// <summary>
/// Test set up.
/// </summary>
Expand Down
Loading
Loading