Skip to content

Commit

Permalink
Merge branch 'master' into proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
florelis committed Feb 27, 2024
2 parents 3172238 + c5fbdd9 commit 2a2def3
Show file tree
Hide file tree
Showing 45 changed files with 1,154 additions and 809 deletions.
11 changes: 8 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,30 +156,31 @@ jobs:
script: |
$(PsExec.secureFilePath) -accepteula -s -i $(buildOutDir)\AppInstallerCLITests\AppInstallerCLITests.exe -logto $(artifactsDir)\AICLI-Unpackaged-System.log -s -r junit -o $(artifactsDir)\TEST-AppInstallerCLI-Unpackaged-System.xml
workingDirectory: '$(buildOutDir)\AppInstallerCLITests'
continueOnError: true
condition: succeededOrFailed()

- task: PowerShell@2
displayName: Create Package Layout
inputs:
filePath: 'src\AppInstallerCLIPackage\Execute-AppxRecipe.ps1'
arguments: '-AppxRecipePath AppInstallerCLIPackage\bin\$(buildPlatform)\$(buildConfiguration)\AppInstallerCLIPackage.build.appxrecipe -LayoutPath $(packageLayoutDir) -Force -Verbose'
workingDirectory: 'src'
continueOnError: true
condition: succeededOrFailed()

- task: PowerShell@2
displayName: Run Unit Tests Packaged
inputs:
filePath: 'src\AppInstallerCLITests\Run-TestsInPackage.ps1'
arguments: '-Args "~[pips]" -BuildRoot $(buildOutDir) -PackageRoot $(packageLayoutDir) -LogTarget $(artifactsDir)\AICLI-Packaged.log -TestResultsTarget $(artifactsDir)\TEST-AppInstallerCLI-Packaged.xml -ScriptWait'
workingDirectory: 'src'
continueOnError: true
condition: succeededOrFailed()

- task: PublishTestResults@2
displayName: Publish Unit Test Results
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '$(artifactsDir)\TEST-*.xml'
failTaskOnFailedTests: true
condition: succeededOrFailed()

- task: MSBuild@1
displayName: Build MSIX Test Installer File
Expand All @@ -191,6 +192,7 @@ jobs:
/p:AppxBundle=Never
/p:UapAppxPackageBuildMode=SideLoadOnly
/p:AppxPackageSigningEnabled=false'
condition: succeededOrFailed()

- task: PowerShell@2
displayName: 'Set program files directory'
Expand All @@ -202,6 +204,7 @@ jobs:
} else {
Write-Host "##vso[task.setvariable variable=platformProgramFiles;]${env:ProgramFiles}"
}
condition: succeededOrFailed()

# Resolves resource strings utilized by InProc E2E tests.
- task: CopyFiles@2
Expand All @@ -210,6 +213,7 @@ jobs:
SourceFolder: '$(buildOutDir)\AppInstallerCLI'
TargetFolder: '$(platformProgramFiles)\dotnet'
Contents: resources.pri
condition: succeededOrFailed()

# Winmd accessed by test runner process (dotnet.exe)
- task: CopyFiles@2
Expand All @@ -218,6 +222,7 @@ jobs:
SourceFolder: '$(buildOutDir)\Microsoft.Management.Deployment'
TargetFolder: '$(platformProgramFiles)\dotnet'
Contents: Microsoft.Management.Deployment.winmd
condition: succeededOrFailed()

- template: templates/e2e-setup.yml
parameters:
Expand Down
8 changes: 4 additions & 4 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"description": "The logging channels to enable",
"type": "array",
"items": {
"uniqueItems": "true",
"uniqueItems": true,
"type": "string",
"enum": [
"fail",
Expand Down Expand Up @@ -104,7 +104,7 @@
"description": "The architecture(s) to use for a package install",
"type": "array",
"items": {
"uniqueItems": "true",
"uniqueItems": true,
"type": "string",
"enum": [
"neutral",
Expand All @@ -121,7 +121,7 @@
"description": "The installerType(s) to use for a package install",
"type": "array",
"items": {
"uniqueItems": "true",
"uniqueItems": true,
"type": "string",
"enum": [
"inno",
Expand Down Expand Up @@ -170,7 +170,7 @@
"defaultInstallRoot": {
"description": "Default install location to use for packages that require it when not specified",
"type": "string",
"maxLength": "32767"
"maxLength": 32767
},
"maxResumes": {
"description": "The maximum number of resumes allowed for a single resume id. This is to prevent continuous reboots if an install that requires a reboot is not properly detected.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ namespace AppInstaller::CLI::Configuration
{
if (!package.Version.empty())
{
auto versionKeys = searchResult.Matches.at(0).Package->GetAvailableVersionKeys();
std::shared_ptr<Repository::IPackage> availablePackage = searchResult.Matches.at(0).Package->GetAvailable().at(0);
auto versionKeys = availablePackage->GetVersionKeys();
bool foundVersion = false;
for (auto const& versionKey : versionKeys)
{
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContextData.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace AppInstaller::CLI::Execution
template <>
struct DataMapping<Data::Package>
{
using value_t = std::shared_ptr<Repository::IPackage>;
using value_t = std::shared_ptr<Repository::ICompositePackage>;
};

template <>
Expand Down
20 changes: 13 additions & 7 deletions src/AppInstallerCLICore/Workflows/CompletionFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ namespace AppInstaller::CLI::Workflow
const std::string& word = context.Get<Data::CompletionData>().Word();
auto stream = context.Reporter.Completion();

for (const auto& vc : context.Get<Execution::Data::Package>()->GetAvailableVersionKeys())
for (const auto& ap : context.Get<Execution::Data::Package>()->GetAvailable())
{
if (word.empty() || Utility::ICUCaseInsensitiveStartsWith(vc.Version, word))
for (const auto& vc : ap->GetVersionKeys())
{
OutputCompletionString(stream, vc.Version);
if (word.empty() || Utility::ICUCaseInsensitiveStartsWith(vc.Version, word))
{
OutputCompletionString(stream, vc.Version);
}
}
}
}
Expand All @@ -86,12 +89,15 @@ namespace AppInstaller::CLI::Workflow

std::vector<std::string> channels;

for (const auto& vc : context.Get<Execution::Data::Package>()->GetAvailableVersionKeys())
for (const auto& ap : context.Get<Execution::Data::Package>()->GetAvailable())
{
if ((word.empty() || Utility::ICUCaseInsensitiveStartsWith(vc.Channel, word)) &&
std::find(channels.begin(), channels.end(), vc.Channel) == channels.end())
for (const auto& vc : ap->GetVersionKeys())
{
channels.emplace_back(vc.Channel);
if ((word.empty() || Utility::ICUCaseInsensitiveStartsWith(vc.Channel, word)) &&
std::find(channels.begin(), channels.end(), vc.Channel) == channels.end())
{
channels.emplace_back(vc.Channel);
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/AppInstallerCLICore/Workflows/DependencyNodeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "DependencyNodeProcessor.h"
#include "ManifestComparator.h"
#include <winget/PinningData.h>
#include <winget/PackageVersionSelection.h>

using namespace AppInstaller::Manifest;
using namespace AppInstaller::Repository;
Expand Down Expand Up @@ -41,20 +42,21 @@ namespace AppInstaller::CLI::Workflow
const auto& match = matches.at(0);
const auto& package = match.Package;
auto packageId = package->GetProperty(PackageProperty::Id);
m_nodePackageInstalledVersion = package->GetInstalledVersion();
m_nodePackageInstalledVersion = GetInstalledVersion(package);
std::shared_ptr<IPackageVersionCollection> availableVersions = GetAvailableVersionsForInstalledVersion(package);

if (m_context.Args.Contains(Execution::Args::Type::Force))
{
m_nodePackageLatestVersion = package->GetLatestAvailableVersion();
m_nodePackageLatestVersion = availableVersions->GetLatestVersion();
}
else
{
Pinning::PinBehavior pinBehavior = m_context.Args.Contains(Execution::Args::Type::IncludePinned) ? Pinning::PinBehavior::IncludePinned : Pinning::PinBehavior::ConsiderPins;

Pinning::PinningData pinningData{ Pinning::PinningData::Disposition::ReadOnly };
auto evaluator = pinningData.CreatePinStateEvaluator(pinBehavior, package->GetInstalledVersion());
auto evaluator = pinningData.CreatePinStateEvaluator(pinBehavior, m_nodePackageInstalledVersion);

m_nodePackageLatestVersion = evaluator.GetLatestAvailableVersionForPins(package);
m_nodePackageLatestVersion = evaluator.GetLatestAvailableVersionForPins(availableVersions);
}

if (m_nodePackageInstalledVersion && dependencyNode.IsVersionOk(Utility::Version(m_nodePackageInstalledVersion->GetProperty(PackageVersionProperty::Version))))
Expand Down
13 changes: 8 additions & 5 deletions src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "WorkflowBase.h"
#include <winget/RepositorySearch.h>
#include <winget/Runtime.h>
#include <winget/PackageVersionSelection.h>

namespace AppInstaller::CLI::Workflow
{
Expand Down Expand Up @@ -60,20 +61,22 @@ namespace AppInstaller::CLI::Workflow
// If requested, checks that the installed version is available and reports a warning if it is not.
std::shared_ptr<IPackageVersion> GetAvailableVersionForInstalledPackage(
Execution::Context& context,
std::shared_ptr<IPackage> package,
std::shared_ptr<ICompositePackage> package,
Utility::LocIndView version,
Utility::LocIndView channel,
bool checkVersion)
{
std::shared_ptr<IPackageVersionCollection> availableVersions = GetAvailableVersionsForInstalledVersion(package);

if (!checkVersion)
{
return package->GetLatestAvailableVersion();
return availableVersions->GetLatestVersion();
}

auto availablePackageVersion = package->GetAvailableVersion({ "", version, channel });
auto availablePackageVersion = availableVersions->GetVersion({ "", version, channel });
if (!availablePackageVersion)
{
availablePackageVersion = package->GetLatestAvailableVersion();
availablePackageVersion = availableVersions->GetLatestVersion();
if (availablePackageVersion)
{
// Warn installed version is not available.
Expand All @@ -100,7 +103,7 @@ namespace AppInstaller::CLI::Workflow
auto& exportedSources = exportedPackages.Sources;
for (const auto& packageMatch : searchResult.Matches)
{
auto installedPackageVersion = packageMatch.Package->GetInstalledVersion();
auto installedPackageVersion = GetInstalledVersion(packageMatch.Package);
auto version = installedPackageVersion->GetProperty(PackageVersionProperty::Version);
auto channel = installedPackageVersion->GetProperty(PackageVersionProperty::Channel);

Expand Down
30 changes: 16 additions & 14 deletions src/AppInstallerCLICore/Workflows/PinFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "TableOutput.h"
#include <winget/PinningData.h>
#include <winget/RepositorySearch.h>
#include <winget/PackageVersionSelection.h>

using namespace AppInstaller::Repository;

Expand Down Expand Up @@ -38,21 +39,20 @@ namespace AppInstaller::CLI::Workflow

if (context.Args.Contains(Execution::Args::Type::PinInstalled))
{
auto installedVersion = package->GetInstalledVersion();
auto installedVersion = GetInstalledVersion(package);
if (installedVersion)
{
pinKeys.emplace(Pinning::PinKey::GetPinKeyForInstalled(installedVersion->GetProperty(PackageVersionProperty::Id)));
}
}
else
{
auto packageVersionKeys = package->GetAvailableVersionKeys();
for (const auto& versionKey : packageVersionKeys)
auto availablePackages = package->GetAvailable();
for (const auto& availablePackage : availablePackages)
{
auto availableVersion = package->GetAvailableVersion(versionKey);
pinKeys.emplace(
availableVersion->GetProperty(PackageVersionProperty::Id).get(),
availableVersion->GetProperty(PackageVersionProperty::SourceIdentifier).get());
availablePackage->GetProperty(PackageProperty::Id).get(),
availablePackage->GetSource().GetIdentifier());
}
}

Expand Down Expand Up @@ -140,7 +140,7 @@ namespace AppInstaller::CLI::Workflow
}
else
{
auto availableVersion = package->GetAvailableVersion({ pinKey.SourceId, "", "" });
auto availableVersion = GetAvailablePackageFromSource(package, pinKey.SourceId)->GetLatestVersion();
if (availableVersion)
{
packageNameToReport = availableVersion->GetProperty(PackageVersionProperty::Name);
Expand Down Expand Up @@ -198,8 +198,6 @@ namespace AppInstaller::CLI::Workflow
// Note that if a source was specified in the command line,
// that will be the only one we get version keys from.
// So, we remove pins from all sources unless one was provided.
auto packageVersionKeys = package->GetAvailableVersionKeys();

for (const auto& pin : pins)
{
AICLI_LOG(CLI, Info, << "Removing Pin " << pin.GetKey().ToString());
Expand Down Expand Up @@ -255,15 +253,19 @@ namespace AppInstaller::CLI::Workflow
else
{
// This ensures we get the info from the right source if it exists on multiple
auto availableVersion = match.Package->GetAvailableVersion({ pinKey.SourceId, "", "" });
if (availableVersion)
auto availablePackage = GetAvailablePackageFromSource(match.Package, pinKey.SourceId);
if (availablePackage)
{
packageName = availableVersion->GetProperty(PackageVersionProperty::Name);
sourceName = availableVersion->GetProperty(PackageVersionProperty::SourceName);
auto availableVersion = availablePackage->GetLatestVersion();
if (availableVersion)
{
packageName = availableVersion->GetProperty(PackageVersionProperty::Name);
sourceName = availableVersion->GetProperty(PackageVersionProperty::SourceName);
}
}
}

auto installedVersion = match.Package->GetInstalledVersion();
auto installedVersion = GetInstalledVersion(match.Package);
if (installedVersion)
{
packageName = installedVersion->GetProperty(PackageVersionProperty::Name);
Expand Down
6 changes: 4 additions & 2 deletions src/AppInstallerCLICore/Workflows/RepairFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "AppInstallerSynchronization.h"
#include "MSStoreInstallerHandler.h"
#include "ManifestComparator.h"
#include <winget/PackageVersionSelection.h>

using namespace AppInstaller::Manifest;
using namespace AppInstaller::Msix;
Expand Down Expand Up @@ -443,10 +444,11 @@ namespace AppInstaller::CLI::Workflow
std::string_view requestedVersion = context.Args.Contains(Execution::Args::Type::Version) ? context.Args.GetArg(Execution::Args::Type::Version) : installedVersion.ToString();
// If it's Store source with only one version unknown, use the unknown version for available version mapping.
const auto& package = context.Get<Execution::Data::Package>();
auto versionKeys = package->GetAvailableVersionKeys();
auto packageVersions = GetAvailableVersionsForInstalledVersion(package, installedPackage);
auto versionKeys = packageVersions->GetVersionKeys();
if (versionKeys.size() == 1)
{
auto packageVersion = package->GetAvailableVersion(versionKeys.at(0));
auto packageVersion = packageVersions->GetVersion(versionKeys.at(0));
if (packageVersion->GetSource().IsWellKnownSource(WellKnownSource::MicrosoftStore) &&
Utility::Version{ packageVersion->GetProperty(PackageVersionProperty::Version) }.IsUnknown())
{
Expand Down
22 changes: 16 additions & 6 deletions src/AppInstallerCLICore/Workflows/UninstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <AppInstallerDeployment.h>
#include <AppInstallerSynchronization.h>
#include <winget/Runtime.h>
#include <winget/PackageVersionSelection.h>

using namespace AppInstaller::CLI::Execution;
using namespace AppInstaller::Manifest;
Expand All @@ -34,9 +35,8 @@ namespace AppInstaller::CLI::Workflow
std::string SourceIdentifier;
};

void AddIfRemoteAndNotPresent(const std::shared_ptr<IPackageVersion>& packageVersion)
void AddIfRemoteAndNotPresent(Source&& source, const Utility::LocIndString& identifier)
{
auto source = packageVersion->GetSource();
const auto details = source.GetDetails();
if (!source.ContainsAvailablePackages())
{
Expand All @@ -51,7 +51,17 @@ namespace AppInstaller::CLI::Workflow
}
}

Items.emplace_back(Item{ packageVersion->GetProperty(PackageVersionProperty::Id), std::move(source), details.Identifier });
Items.emplace_back(Item{ identifier, std::move(source), details.Identifier });
}

void AddIfRemoteAndNotPresent(const std::shared_ptr<IPackageVersion>& packageVersion)
{
AddIfRemoteAndNotPresent(packageVersion->GetSource(), packageVersion->GetProperty(PackageVersionProperty::Id));
}

void AddIfRemoteAndNotPresent(const std::shared_ptr<IPackage>& package)
{
AddIfRemoteAndNotPresent(package->GetSource(), package->GetProperty(PackageProperty::Id));
}

std::vector<Item> Items;
Expand Down Expand Up @@ -311,12 +321,12 @@ namespace AppInstaller::CLI::Workflow
UninstallCorrelatedSources correlatedSources;

// Start with the installed version
correlatedSources.AddIfRemoteAndNotPresent(package->GetInstalledVersion());
correlatedSources.AddIfRemoteAndNotPresent(GetInstalledVersion(package));

// Then look through all available versions
for (const auto& versionKey : package->GetAvailableVersionKeys())
for (const auto& availablePackage : package->GetAvailable())
{
correlatedSources.AddIfRemoteAndNotPresent(package->GetAvailableVersion(versionKey));
correlatedSources.AddIfRemoteAndNotPresent(availablePackage);
}

// Finally record the uninstall for each found value
Expand Down
Loading

0 comments on commit 2a2def3

Please sign in to comment.