none
PackageManager.CheckUpdateAvailabilityAsync() RRS feed

  • Question

  • In my Universal Windows application, I use one application to update two other UWP applications. The application has the packageManagement restricted capabilites, etc. I have everything set up for the application to see if the other 2 apps are installed, see if there are updates for them, install the updates, and then launch the selected app. We deploy each of our applications using AppInstaller. We have appinstaller files generated for each app, and we use PackageManager.CheckUpdateAvailabilityAsync() to check for new updates to the apps. In our development environment this works fine. In production, we get an access denied error upon checking for updates for the applications. This is the Event Viewer log that we get. I believe this is failing at the stage that the above method is attempting to check for updates.

    I've tried everything that I can think of on the network share to allow access to SYSTEM, NETWORK SERVICE, and the Network name of the PC I'm running from. My user is within a group that has full access to this share, etc. Each and every time that this method is called, I receive the access denied error. I've compared the folder access from within our development environment, etc. 

    What user would this application/method run as? If I can figure out what user a UWP app runs as, I may be able to find out what permissions I need to provide to that share to make everything work.

    Any other ideas? Sample method code is below:

    public static async Task<bool> InstallOrUpdateAppAsync(string installerLocation, string packageName)
            {
                var packageManager = new PackageManager();

                //is app installed?
                var isInstalled = await IsAppInstalledAsync(packageName);

                if (isInstalled)
                {
                    //grab the package we want to update.
                    var package = packageManager.FindPackagesForUser(string.Empty, packageName).FirstOrDefault();

                    if (package != null)
                    {
                        //for apps installed via Appinstaller file, this method will return whether there's an app update available
                        var requiresUpdate = await package.CheckUpdateAvailabilityAsync();

                        if (requiresUpdate.Availability != PackageUpdateAvailability.NoUpdates && requiresUpdate.Availability != PackageUpdateAvailability.Error)
                        {
                            try
                            {
                                var packageVolume = packageManager.GetDefaultPackageVolume();
                                await packageManager.AddPackageByAppInstallerFileAsync(new Uri(installerLocation), AddPackageByAppInstallerOptions.ForceTargetAppShutdown, packageVolume);

                                return true;
                            }
                            catch (Exception e)
                            {
                                var log = LogManagerFactory.Instance.DefaultLogManager.GetLogger<InstallHelper>();
                                log.Error("Error updating app..." + e.Message);
                                return false;
                            }

                        }
                    }
                }
                else
                {
                    try
                    {
                        var packageVolume = packageManager.GetDefaultPackageVolume();
                        await packageManager.AddPackageByAppInstallerFileAsync(new Uri(installerLocation), AddPackageByAppInstallerOptions.ForceTargetAppShutdown, packageVolume);

                        return true;
                    }
                    catch(Exception e)
                    {
                        var log = LogManagerFactory.Instance.DefaultLogManager.GetLogger<InstallHelper>();
                        log.Error("Error installing app..." + e.Message);
                        return false;
                    }
                }

                return false;
            }


    Monday, June 10, 2019 11:08 PM

Answers

  • Thanks for the reply Roy. I feel obligated to give an answer to my own question for other folks that might run into this problem. When it comes to network shares, there are a couple of ways to define permissions on a share. I was confused thinking that when I was editing in the Permissions tab as seen below, I was also configuring who was able to access the share. This is not the case. Once the permissions were updated on the Share tab, the problem was fixed. 

    Windows file share permissions

    • Marked as answer by Ezra Ward Tuesday, August 27, 2019 7:44 PM
    Tuesday, August 27, 2019 7:43 PM

All replies

  • Hi,

    I have a question here. What's the difference between your development environment and production environment? It's strange what changes makes the different behaviors. 

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 11, 2019 8:27 AM
    Moderator
  • Thanks for the reply Roy. I feel obligated to give an answer to my own question for other folks that might run into this problem. When it comes to network shares, there are a couple of ways to define permissions on a share. I was confused thinking that when I was editing in the Permissions tab as seen below, I was also configuring who was able to access the share. This is not the case. Once the permissions were updated on the Share tab, the problem was fixed. 

    Windows file share permissions

    • Marked as answer by Ezra Ward Tuesday, August 27, 2019 7:44 PM
    Tuesday, August 27, 2019 7:43 PM