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
11 changes: 8 additions & 3 deletions src/UniGetUI.PackageEngine.Managers.WinGet/WinGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,15 @@ Func<string, bool> fileExists
}

internal IWinGetManagerHelper CreateCliHelperForSelectedCliTool()
{
return CreateCliHelperForSelectedCliTool(Status.ExecutablePath);
}

internal IWinGetManagerHelper CreateCliHelperForSelectedCliTool(string executablePath)
{
return SelectedCliToolKind == WinGetCliToolKind.BundledPinget
? new PingetCliHelper(this, Status.ExecutablePath)
: new WinGetCliHelper(this, Status.ExecutablePath);
? new PingetCliHelper(this, executablePath)
: new WinGetCliHelper(this, executablePath);
}

protected override void _loadManagerExecutableFile(
Expand Down Expand Up @@ -449,7 +454,7 @@ ex is WinGetComActivationException activationEx
}

Logger.Warn("WinGet will resort to using WinGetCliHelper()");
WinGetHelper.Instance = CreateCliHelperForSelectedCliTool();
WinGetHelper.Instance = CreateCliHelperForSelectedCliTool(path);
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/UniGetUI.PackageEngine.Tests/WinGetManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,25 @@ public void ShouldUseWinGetComApiNeverUsesComForBundledPingetCliTool()
);
}

[Fact]
public void CreateCliHelperForSelectedCliToolUsesExplicitExecutablePath()
{
var manager = new WinGet();
SetCliToolKind(manager, WinGetCliToolKind.SystemWinGet);

IWinGetManagerHelper helper = manager.CreateCliHelperForSelectedCliTool(
@"C:\WindowsApps\winget.exe"
);

var pathField = typeof(WinGetCliHelper).GetField(
"_cliExecutablePath",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic
);

Assert.NotNull(pathField);
Assert.Equal(@"C:\WindowsApps\winget.exe", pathField.GetValue(helper));
}

[Fact]
public void NativeWinGetHelperUsesSystemCliFallbackForInstalledPackagesWhenCompositeCatalogFails()
{
Expand Down
Loading