winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 006601be7b56f7fad4b4f83e8317b8bd9358e0f6
parent 926a2f51704f2e767e259c746596213a5eb4268a
Author: sachintaMSFT <80828309+sachintaMSFT@users.noreply.github.com>
Date:   Fri,  9 Jul 2021 18:21:50 -0700

Add Microsoft Store REST Source as default option and fix telemetry gaps (#1216)

Added Microsoft Store REST Source as Restricted source to WellKnownSources and part of MSStore Experimental Feature. Ensured COM APIs doesn't get affected by winget command line removal of WellKnownSources. Additionally, fixed gaps found in telemetry during data validation.

Diffstat:
M.github/actions/spelling/allow.txt | 1125++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/AppInstallerCLICore/COMContext.cpp | 1-
Msrc/AppInstallerCommonCore/AppInstallerTelemetry.cpp | 2++
Msrc/AppInstallerRepositoryCore/Public/AppInstallerRepositorySource.h | 4++++
Msrc/AppInstallerRepositoryCore/RepositorySource.cpp | 73++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Msrc/Microsoft.Management.Deployment/PackageManager.cpp | 20++++++++++++--------
Msrc/Microsoft.Management.Deployment/PackageManager.idl | 1+
Msrc/WinGetServer/WinMain.cpp | 7++++++-
8 files changed, 645 insertions(+), 588 deletions(-)

diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt @@ -1,561 +1,564 @@ -abi -ACCESSDENIED -addmanifest -addstore -admins -alloc -anonymize -api -appdata -appinst -appinstaller -appmodel -apps -appx -appxbundle -appxmanifest -appxsdk -APSTUDIO -argc -args -argv -ARRAYSIZE -aspirational -aspnet -authn -authz -autocomplete -auxdata -azureedge -bcp -bcp47 -bcrypt -binver -Bitmask -blog -Blog -boolalpha -bstr -bugfix -BUILDNUMBER -bytearray -cdecl -cer -certutil -chrono -cin -cla -CLSCTX -cmake -cmp -CNG -cnt -codepage -COMMANDBARFLYOUT -Commandline -comparand -conemu -config -Configurability -constexpr -Contoso -copyable -COSTDEFERRED -cotaskmem -cout -cpp -cppreference -cpprest -cpprestsdk -cppwinrt -CPRWL -createnew -createtables -cref -csproj -CStr -CURSORPOSITON -cwctype -datatelemetry -dbconn -DBId -declspec -decltype -declval -defaultlocale -delstore -Demitrius -denelon -depersist -Deserialize -deserializer -deserializing -dest -devblogs -differentpath -distro -DIRECTONLY -dll -dllexport -docx -dotnet -downlevel -downloader -downloaders -dword -DWORDLONG -elseif -emoji -endif -endl -ensureandinsert -ensurepathexists -ENU -enum -EOAC -errorlevel -errstr -esrp -etag -ETW -EVENTTAG -exe -executables -exeenus -exeinteractive -exelog -exesilent -exeswp -exitcode -expr -EXTRAFLAGS -FAILIFTHERE -fakeswitch -FIELDTAG -FILEFLAGS -FILEFLAGSMASK -FILELOGGER -FILEOS -filepath -FILESUBTYPE -filesystem -FILETYPE -FILEVERSION -foreach -fstream -func -gcount -gdi -getline -github -githubusercontent -hfile -HGLOBAL -hinternet -HKEY -hmac -HMODULE -homepage -Homepage -hostname -hpp -HRESULT -hresult -HRSRC -hstring -html -http -https -Hyperlink -IApplication -IAppx -IAsync -IBuffer -icu -IDisposable -IDX -IEnumerable -IFACEMETHOD -ifdef -ifndef -ifstream -IInput -IInspectable -IIS -ILogger -impl -Inet -inno -INPROC -Inq -installertype -Installeruniqueness -installlocation -INSTALLPATH -interop -INVALIDARG -iomanip -iostream -IOutput -IProgress -IRandom -IRest -ISAPPROVEDFOROUTPUT -ISource -isspace -istream -istringstream -IUnknown -json -junit -langutil -lastwritetime -LCID -LCIDTo -LEN -Linux -LLVM -llvmorg -LOCALAPPDATA -localtime -LOGPATH -logsql -logto -LONGLONG -LPCGUID -LPVOID -mailto -MAJORVERSION -makeappx -MAKEINTRESOURCE -makemsix -MANIFESTSCHEMA -MANIFESTVERSION -MBs -mday -memset -metadata -microsoft -mimetype -Minimatch -MINORVERSION -mkdir -monostate -motw -mrm -msbuild -msdata -MSDN -msi -msiexec -msix -msixbundle -msixinfo -msixsdk -msixsdkx -msixtest -msrc -Multifile -Multimatch -mutex -mutexes -namespace -namespaces -Nelon -netcoreapp -newid -NOCLOSEPROCESS -nodiscard -noexcept -nomem -NOMINMAX -NONAME -nonexistentsetting -NONINFRINGEMENT -NOTHROW -NOTIMPL -NOTNULL -npos -NTFS -NTSTATUS -nuget -nullptr -nullsoft -nupkg -nuspec -nunit -OAuth -ofstream -opencode -opensource -ostream -ostringstream -OSVERSIONINFOEXW -outfile -OUTOFMEMORY -OWC -PACKAGESSCHEMA -Params -params -parentidx -pathpart -Pathto -PBYTE -pch -PCWSTR -pdb -PEVENT -pfp -PGP -PII -pipssource -placeholders -png -posix -powershell -PPV -pplx -pragma -PRECONFIG -preindexed -prepareforpackaging -PRIMARYKEY -prioritization -PRODUCTNAME -PRODUCTVERSION -psz -ptr -publiccontainer -PUCHAR -PVOID -pwa -QCol -RAII -rclsid -rdbuf -README -READONLY -READWRITE -realloc -REALTIME -Redistributable -REFCLSID -regex -regexp -removemanifest -repolibtest -rescap -resheader -resmimetype -RESTSOURCE -resw -resx -roadmap -robuffer -rowcount -rowid -Rpc -rubengustorage -ruleset -runsettings -runtimes -safecast -SANITIZERS -savepoint -screenshots -SCROLLER -SCROLLVIEWER -sdk -seekg -seinfo -selectany -SERVICEPACKMAJOR -SERVICEPACKMINOR -setfill -setschemaversion -setvariable -setw -shcore -shellapi -SHELLEXEC -SHELLEXECUTEINFO -SHELLEXECUTEINFOA -SHELLEXECUTEINFOW -Shlwapi -signtool -silentwithprogress -simplesave -simpletest -sizeof -sln -SNAME -snprintf -sourced -Specv -sprintf -sql -sqlbuilder -sqlite -sqliteicu -sqliteindex -sqliteindexsource -sqlitewrapper -srand -src -srwlock -sscanf -sstream -STATFLAG -STATSTG -stdcall -stderr -stdexcept -stdout -STGM -stmt -stoi -stoll -stoull -strcoll -streamoff -streampos -stricmp -strikethrough -STRINGID -STRINGIFY -STRINGIZE -stringstream -strstr -subcontext -SUBLANG -subresource -subselect -substr -SWIPECONTROL -SYMED -Sys -sz -TARG -TARGETDIR -targetentrypoint -targetnametoken -tdbuild -tdd -tellg -tempdb -terabyte -testcontainer -testmoniker -Testrun -testsettingname -TEXTFORMAT -TEXTINCLUDE -there're -Timeline -todo -tolower -toupper -towlower -TRACELOGGING -triaged -trunc -TRUSTEDPEOPLE -tt -ttl -typedef -typename -UAC -uap -UBool -UBreak -ubrk -uchar -ucol -UCollation -UCollator -UError -UIA -UIF -uint -Uknown -ulong -ULONGLONG -uncomment -und -undef -unicode -UNICODESTRING -uninstall -uninstalling -Unregister -updatemanifest -UPLEVEL -upvote -uregex -URegular -uri -url -urlmon -userguide -USERPROFILE -usersources -utext -utf -uuidof -validator -valijson -vcvars -vcxitems -vcxproj -vdproj -versioned -VERSIONINFO -versioning -VERYSILENT -VFT -visualstudio -vm -VOS -vso -wapproj -wchar -wcout -wcsicmp -webpage -wekyb -wil -WINAPI -WINEVENT -winget -wininet -winmeta -winres -winrt -winsqlite -wix -wmain -woah -wofstream -workaround -workflow -wostringstream -wostream -wpfn -wrl -WStr -wstring -wstringstream -www -xamarin -xlang -xml -xmlns -XElement -XName -XResource -xsd -XTOKEN -yaml -yml -yy -zh +abi +ACCESSDENIED +addmanifest +addstore +admins +alloc +anonymize +api +appdata +appinst +appinstaller +appmodel +apps +appx +appxbundle +appxmanifest +appxsdk +APSTUDIO +argc +args +argv +ARRAYSIZE +aspirational +aspnet +authn +authz +autocomplete +auxdata +azureedge +bcp +bcp47 +bcrypt +binver +Bitmask +blog +Blog +boolalpha +bstr +bugfix +BUILDNUMBER +bytearray +cdecl +cer +certutil +chrono +cin +cla +CLSCTX +cmake +cmp +CNG +cnt +codepage +COMMANDBARFLYOUT +Commandline +comparand +conemu +config +Configurability +constexpr +Contoso +copyable +COSTDEFERRED +cotaskmem +cout +cpp +cppreference +cpprest +cpprestsdk +cppwinrt +CPRWL +createnew +createtables +cref +csproj +CStr +CURSORPOSITON +cwctype +datatelemetry +dbconn +DBId +declspec +decltype +declval +defaultlocale +delstore +Demitrius +denelon +depersist +Deserialize +deserializer +deserializing +dest +devblogs +differentpath +distro +DIRECTONLY +dll +dllexport +docx +dotnet +downlevel +downloader +downloaders +dsx +dword +DWORDLONG +elseif +emoji +endif +endl +ensureandinsert +ensurepathexists +ENU +enum +EOAC +errorlevel +errstr +esrp +etag +ETW +EVENTTAG +exe +executables +exeenus +exeinteractive +exelog +exesilent +exeswp +exitcode +expr +EXTRAFLAGS +FAILIFTHERE +fakeswitch +FIELDTAG +FILEFLAGS +FILEFLAGSMASK +FILELOGGER +FILEOS +filepath +FILESUBTYPE +filesystem +FILETYPE +FILEVERSION +foreach +fstream +func +gcount +gdi +getline +github +githubusercontent +hfile +HGLOBAL +hinternet +HKEY +hmac +HMODULE +homepage +Homepage +hostname +hpp +HRESULT +hresult +HRSRC +hstring +html +http +https +Hyperlink +IApplication +IAppx +IAsync +IBuffer +icu +IDisposable +IDX +IEnumerable +IFACEMETHOD +ifdef +ifndef +ifstream +IInput +IInspectable +IIS +ILogger +impl +Inet +inno +INPROC +Inq +installertype +Installeruniqueness +installlocation +INSTALLPATH +interop +INVALIDARG +iomanip +iostream +IOutput +IProgress +IRandom +IRest +ISAPPROVEDFOROUTPUT +ISource +isspace +istream +istringstream +IUnknown +json +junit +langutil +lastwritetime +LCID +LCIDTo +LEN +Linux +LLVM +llvmorg +LOCALAPPDATA +localtime +LOGPATH +logsql +logto +LONGLONG +LPCGUID +LPVOID +mailto +MAJORVERSION +makeappx +MAKEINTRESOURCE +makemsix +MANIFESTSCHEMA +MANIFESTVERSION +MBs +mday +memset +metadata +microsoft +mimetype +Minimatch +MINORVERSION +mkdir +monostate +motw +mrm +msbuild +msdata +MSDN +msi +msiexec +msix +msixbundle +msixinfo +msixsdk +msixsdkx +msixtest +msrc +Multifile +Multimatch +mutex +mutexes +namespace +namespaces +Nelon +netcoreapp +newid +NOCLOSEPROCESS +nodiscard +noexcept +nomem +NOMINMAX +NONAME +nonexistentsetting +NONINFRINGEMENT +NOTHROW +NOTIMPL +NOTNULL +npos +NTFS +NTSTATUS +nuget +nullptr +nullsoft +nupkg +nuspec +nunit +OAuth +ofstream +opencode +opensource +ostream +ostringstream +OSVERSIONINFOEXW +outfile +OUTOFMEMORY +OWC +PACKAGESSCHEMA +Params +params +parentidx +pathpart +Pathto +PBYTE +pch +PCWSTR +pdb +PEVENT +pfp +PGP +PII +pipssource +placeholders +png +posix +powershell +PPV +pplx +pragma +PRECONFIG +preindexed +prepareforpackaging +PRIMARYKEY +prioritization +PRODUCTNAME +PRODUCTVERSION +psz +ptr +publiccontainer +PUCHAR +PVOID +pwa +QCol +RAII +rclsid +rdbuf +README +READONLY +READWRITE +realloc +REALTIME +Redistributable +REFCLSID +regex +regexp +removemanifest +repolibtest +rescap +resheader +resmimetype +RESTSOURCE +resw +resx +roadmap +robuffer +rowcount +rowid +Rpc +rubengustorage +ruleset +runsettings +runtimes +safecast +SANITIZERS +savepoint +screenshots +SCROLLER +SCROLLVIEWER +sdk +seekg +seinfo +selectany +SERVICEPACKMAJOR +SERVICEPACKMINOR +setfill +setschemaversion +setvariable +setw +shcore +shellapi +SHELLEXEC +SHELLEXECUTEINFO +SHELLEXECUTEINFOA +SHELLEXECUTEINFOW +Shlwapi +signtool +silentwithprogress +simplesave +simpletest +sizeof +sln +SNAME +snprintf +sourced +Specv +sprintf +sql +sqlbuilder +sqlite +sqliteicu +sqliteindex +sqliteindexsource +sqlitewrapper +srand +src +srwlock +sscanf +sstream +STATFLAG +STATSTG +stdcall +stderr +stdexcept +stdout +STGM +stmt +stoi +stoll +storeedgefd +storepreview +stoull +strcoll +streamoff +streampos +stricmp +strikethrough +STRINGID +STRINGIFY +STRINGIZE +stringstream +strstr +subcontext +SUBLANG +subresource +subselect +substr +SWIPECONTROL +SYMED +Sys +sz +TARG +TARGETDIR +targetentrypoint +targetnametoken +tdbuild +tdd +tellg +tempdb +terabyte +testcontainer +testmoniker +Testrun +testsettingname +TEXTFORMAT +TEXTINCLUDE +there're +Timeline +todo +tolower +toupper +towlower +TRACELOGGING +triaged +trunc +TRUSTEDPEOPLE +tt +ttl +typedef +typename +UAC +uap +UBool +UBreak +ubrk +uchar +ucol +UCollation +UCollator +UError +UIA +UIF +uint +Uknown +ulong +ULONGLONG +uncomment +und +undef +unicode +UNICODESTRING +uninstall +uninstalling +Unregister +updatemanifest +UPLEVEL +upvote +uregex +URegular +uri +url +urlmon +userguide +USERPROFILE +usersources +utext +utf +uuidof +validator +valijson +vcvars +vcxitems +vcxproj +vdproj +versioned +VERSIONINFO +versioning +VERYSILENT +VFT +visualstudio +vm +VOS +vso +wapproj +wchar +wcout +wcsicmp +webpage +wekyb +wil +WINAPI +WINEVENT +winget +wininet +winmeta +winres +winrt +winsqlite +wix +wmain +woah +wofstream +workaround +workflow +wostringstream +wostream +wpfn +wrl +WStr +wstring +wstringstream +www +xamarin +xlang +xml +xmlns +XElement +XName +XResource +xsd +XTOKEN +yaml +yml +yy +zh diff --git a/src/AppInstallerCLICore/COMContext.cpp b/src/AppInstallerCLICore/COMContext.cpp @@ -36,7 +36,6 @@ namespace AppInstaller void COMContext::SetLoggerContext(const std::wstring_view telemetryCorelationJson, const std::string& caller) { - Logging::SetActivityId(); Logging::Telemetry().SetTelemetryCorelationJson(telemetryCorelationJson); Logging::Telemetry().SetCaller(caller); Logging::Telemetry().LogStartup(true); diff --git a/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp b/src/AppInstallerCommonCore/AppInstallerTelemetry.cpp @@ -179,6 +179,8 @@ namespace AppInstaller::Logging packageVersion = Runtime::GetPackageVersion(); } + Logging::SetActivityId(); + if (IsTelemetryEnabled()) { AICLI_TraceLoggingWriteActivity( diff --git a/src/AppInstallerRepositoryCore/Public/AppInstallerRepositorySource.h b/src/AppInstallerRepositoryCore/Public/AppInstallerRepositorySource.h @@ -62,6 +62,9 @@ namespace AppInstaller::Repository // The trust level of the source SourceTrustLevel TrustLevel = SourceTrustLevel::None; + + // Whether the source behavior has restrictions + bool Restricted = false; }; // Interface for interacting with a source from outside of the repository lib. @@ -134,6 +137,7 @@ namespace AppInstaller::Repository enum class WellKnownSource { WinGet, + MicrosoftStore, }; SourceDetails GetPredefinedSourceDetails(PredefinedSource source); diff --git a/src/AppInstallerRepositoryCore/RepositorySource.cpp b/src/AppInstallerRepositoryCore/RepositorySource.cpp @@ -40,6 +40,10 @@ namespace AppInstaller::Repository constexpr std::string_view s_Source_WingetMSStoreDefault_Data = "Microsoft.Winget.MSStore.Source_8wekyb3d8bbwe"sv; constexpr std::string_view s_Source_WingetMSStoreDefault_Identifier = "Microsoft.Winget.MSStore.Source_8wekyb3d8bbwe"sv; + constexpr std::string_view s_Source_MSStoreDefault_Name = "storepreview"sv; + constexpr std::string_view s_Source_MSStoreDefault_Arg = "https://storeedgefd.dsx.mp.microsoft.com/v9.0"sv; + constexpr std::string_view s_Source_MSStoreDefault_Identifier = "StoreEdgeFD"sv; + namespace { // SourceDetails with additional data. @@ -47,6 +51,10 @@ namespace AppInstaller::Repository { // If true, this is a tombstone, marking the deletion of a source at a lower priority origin. bool IsTombstone = false; + + SourceDetailsInternal() = default; + + SourceDetailsInternal(const SourceDetails& details) : SourceDetails(details) {}; }; // Checks whether a default source is enabled with the current settings. @@ -84,6 +92,11 @@ namespace AppInstaller::Repository return IsDefaultSourceEnabled(s_Source_WingetMSStoreDefault_Name, ExperimentalFeature::Feature::ExperimentalMSStore, onlyExplicit, TogglePolicy::Policy::MSStoreSource); } + bool IsMSStoreDefaultSourceEnabled(bool onlyExplicit = false) + { + return IsDefaultSourceEnabled(s_Source_MSStoreDefault_Name, ExperimentalFeature::Feature::ExperimentalMSStore, onlyExplicit, TogglePolicy::Policy::MSStoreSource); + } + template<ValuePolicy P> std::optional<SourceFromPolicy> FindSourceInPolicy(std::string_view name, std::string_view type, std::string_view arg) { @@ -396,14 +409,7 @@ namespace AppInstaller::Repository { if (IsWingetCommunityDefaultSourceEnabled()) { - SourceDetailsInternal details; - details.Name = s_Source_WingetCommunityDefault_Name; - details.Type = Microsoft::PreIndexedPackageSourceFactory::Type(); - details.Arg = s_Source_WingetCommunityDefault_Arg; - details.Data = s_Source_WingetCommunityDefault_Data; - details.Identifier = s_Source_WingetCommunityDefault_Identifier; - details.TrustLevel = SourceTrustLevel::Trusted | SourceTrustLevel::StoreOrigin; - result.emplace_back(std::move(details)); + result.emplace_back(GetWellKnownSourceDetails(WellKnownSource::WinGet)); } if (IsWingetMSStoreDefaultSourceEnabled()) @@ -417,6 +423,11 @@ namespace AppInstaller::Repository details.TrustLevel = SourceTrustLevel::Trusted | SourceTrustLevel::StoreOrigin; result.emplace_back(std::move(details)); } + + if (IsMSStoreDefaultSourceEnabled()) + { + result.emplace_back(GetWellKnownSourceDetails(WellKnownSource::MicrosoftStore)); + } } break; case SourceOrigin::User: @@ -914,8 +925,17 @@ namespace AppInstaller::Repository } else if (currentSources.size() == 1) { - AICLI_LOG(Repo, Info, << "Default source requested, only 1 source available, using the only source: " << currentSources[0].get().Name); - return OpenSource(currentSources[0].get().Name, progress); + // Restricted sources may not support the full set of functionality + if (currentSources[0].get().Restricted) + { + AICLI_LOG(Repo, Info, << "Default source requested, only 1 source available but not using it as it is restricted: " << currentSources[0].get().Name); + return {}; + } + else + { + AICLI_LOG(Repo, Info, << "Default source requested, only 1 source available, using the only source: " << currentSources[0].get().Name); + return OpenSource(currentSources[0].get().Name, progress); + } } else { @@ -926,6 +946,13 @@ namespace AppInstaller::Repository bool sourceUpdated = false; for (auto& source : currentSources) { + // Restricted sources may not support the full set of functionality so they shouldn't be included in the default aggregated source. + if (source.get().Restricted) + { + AICLI_LOG(Repo, Info, << "Skipping adding to aggregated source as the current source is restricted: " << source.get().Name); + continue; + } + AICLI_LOG(Repo, Info, << "Adding to aggregated source: " << source.get().Name); if (ShouldUpdateBeforeOpen(source)) @@ -942,6 +969,7 @@ namespace AppInstaller::Repository result.SourcesWithUpdateFailure.emplace_back(source); } } + aggregatedSource->AddAvailableSource(CreateSourceFromDetails(source, progress)); } @@ -1006,12 +1034,9 @@ namespace AppInstaller::Repository AICLI_LOG(Repo, Info, << "Named source no longer found. Source may have been removed by the user: " << details.Name); return {}; } - else if (source->IsTombstone) - { - AICLI_LOG(Repo, Info, << "Named source no longer found. Source was tombstoned: " << details.Name); - return {}; - } - if (ShouldUpdateBeforeOpen(*source)) + + if (!source->Restricted && + ShouldUpdateBeforeOpen(*source)) { try { @@ -1036,7 +1061,7 @@ namespace AppInstaller::Repository { SourceDetails details = GetPredefinedSourceDetails(source); return CreateSourceFromDetails(details, progress); - } + } SourceDetails GetPredefinedSourceDetails(PredefinedSource source) { @@ -1067,6 +1092,7 @@ namespace AppInstaller::Repository switch (source) { case WellKnownSource::WinGet: + { SourceDetailsInternal details; details.Origin = SourceOrigin::Default; details.Name = s_Source_WingetCommunityDefault_Name; @@ -1077,6 +1103,19 @@ namespace AppInstaller::Repository details.TrustLevel = SourceTrustLevel::Trusted | SourceTrustLevel::StoreOrigin; return details; } + case WellKnownSource::MicrosoftStore: + { + SourceDetailsInternal details; + details.Origin = SourceOrigin::Default; + details.Name = s_Source_MSStoreDefault_Name; + details.Type = Rest::RestSourceFactory::Type(); + details.Arg = s_Source_MSStoreDefault_Arg; + details.Identifier = s_Source_MSStoreDefault_Identifier; + details.TrustLevel = SourceTrustLevel::Trusted; + details.Restricted = true; + return details; + } + } THROW_HR(E_UNEXPECTED); } diff --git a/src/Microsoft.Management.Deployment/PackageManager.cpp b/src/Microsoft.Management.Deployment/PackageManager.cpp @@ -55,17 +55,19 @@ namespace winrt::Microsoft::Management::Deployment::implementation switch (predefinedPackageCatalog) { case winrt::Microsoft::Management::Deployment::PredefinedPackageCatalog::OpenWindowsCatalog: - { - sourceDetails = GetWellKnownSourceDetails(::AppInstaller::Repository::WellKnownSource::WinGet); - auto packageCatalogInfo = winrt::make_self<wil::details::module_count_wrapper<winrt::Microsoft::Management::Deployment::implementation::PackageCatalogInfo>>(); - packageCatalogInfo->Initialize(sourceDetails); - auto packageCatalogRef = winrt::make_self<wil::details::module_count_wrapper<winrt::Microsoft::Management::Deployment::implementation::PackageCatalogReference>>(); - packageCatalogRef->Initialize(*packageCatalogInfo); - return *packageCatalogRef; - } + sourceDetails = GetWellKnownSourceDetails(::AppInstaller::Repository::WellKnownSource::WinGet); + break; + case winrt::Microsoft::Management::Deployment::PredefinedPackageCatalog::MicrosoftStore: + sourceDetails = GetWellKnownSourceDetails(::AppInstaller::Repository::WellKnownSource::MicrosoftStore); + break; default: throw hresult_invalid_argument(); } + auto packageCatalogInfo = winrt::make_self<wil::details::module_count_wrapper<winrt::Microsoft::Management::Deployment::implementation::PackageCatalogInfo>>(); + packageCatalogInfo->Initialize(sourceDetails); + auto packageCatalogRef = winrt::make_self<wil::details::module_count_wrapper<winrt::Microsoft::Management::Deployment::implementation::PackageCatalogReference>>(); + packageCatalogRef->Initialize(*packageCatalogInfo); + return *packageCatalogRef; } winrt::Microsoft::Management::Deployment::PackageCatalogReference PackageManager::GetLocalPackageCatalog(winrt::Microsoft::Management::Deployment::LocalPackageCatalog const& localPackageCatalog) { @@ -232,6 +234,8 @@ namespace winrt::Microsoft::Management::Deployment::implementation std::unique_ptr<::AppInstaller::CLI::Command> command = std::make_unique<::AppInstaller::CLI::InstallCommand>(rootCommand.Name()); rootCommand.ValidateArguments(context.Args); + ::AppInstaller::Logging::Telemetry().LogCommand(command->FullName()); + context.SetProgressCallbackFunction([=]( ::AppInstaller::ReportType reportType, uint64_t current, diff --git a/src/Microsoft.Management.Deployment/PackageManager.idl b/src/Microsoft.Management.Deployment/PackageManager.idl @@ -401,6 +401,7 @@ namespace Microsoft.Management.Deployment enum PredefinedPackageCatalog { OpenWindowsCatalog, + MicrosoftStore, }; /// Local Catalogs with PackageCatalogOrigin Predefined diff --git a/src/WinGetServer/WinMain.cpp b/src/WinGetServer/WinMain.cpp @@ -6,6 +6,8 @@ #include <winget/ExperimentalFeature.h> #include <winget/GroupPolicy.h> #include "COMContext.h" +#include "AppInstallerRuntime.h" +#include "AppInstallerVersions.h" using namespace winrt::Microsoft::Management::Deployment; @@ -33,7 +35,10 @@ static void _releaseNotifier() noexcept // Check whether the packaged api is enabled and the overarching winget group policy is enabled. bool IsServerEnabled() { - if (!::AppInstaller::Settings::ExperimentalFeature::IsEnabled(::AppInstaller::Settings::ExperimentalFeature::Feature::PackagedAPI)) + ::AppInstaller::Utility::Version version("10.0.22000.0"); + + if (!::AppInstaller::Runtime::IsCurrentOSVersionGreaterThanOrEqual(version) && + !::AppInstaller::Settings::ExperimentalFeature::IsEnabled(::AppInstaller::Settings::ExperimentalFeature::Feature::PackagedAPI)) { return false; }