public void OnPackageInstalling(PackageCatalog p, PackageInstallingEventArgs args)
        {
            if (args.IsComplete)
            {
                try
                {
                    var packageWrapper = PackageWrapper.GetWrapperFromPackage(args.Package);
                    if (!string.IsNullOrEmpty(packageWrapper.InstalledLocation))
                    {
                        var uwp = new UWP(packageWrapper);
                        uwp.InitializeAppInfo(packageWrapper.InstalledLocation);
                        foreach (var app in uwp.Apps)
                        {
                            Add(app);
                        }
                    }
                }

                // InitializeAppInfo will throw if there is no AppxManifest.xml for the package.
                // Note there are sometimes multiple packages per product and this doesn't necessarily mean that we haven't found the app.
                // eg. "Could not find file 'C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_2020.616.45.0_neutral_~_8wekyb3d8bbwe\\AppxManifest.xml'."
                catch (System.IO.FileNotFoundException e)
                {
                    ProgramLogger.Exception(e.Message, e, GetType(), args.Package.InstalledLocation.ToString());
                }
            }
        }
Esempio n. 2
0
        public void OnPackageInstalling(PackageCatalog p, PackageInstallingEventArgs args)
        {
            if (args.IsComplete)
            {
                try
                {
                    var uwp = new UWP(args.Package);
                    uwp.InitializeAppInfo(args.Package.InstalledLocation.Path);
                    foreach (var app in uwp.Apps)
                    {
                        Add(app);
                    }
                }
                //InitializeAppInfo will throw if there is no AppxManifest.xml for the package.
                //Note there are sometimes multiple packages per product and this doesn't necessarily mean that we haven't found the app.
                //eg. "Could not find file 'C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_2020.616.45.0_neutral_~_8wekyb3d8bbwe\\AppxManifest.xml'."

                catch (System.IO.FileNotFoundException e)
                {
                    ProgramLogger.LogException($"|UWP|OnPackageInstalling|{args.Package.InstalledLocation}|{e.Message}", e);
                }
            }
        }