Esempio n. 1
0
        /// <summary>
        /// Deletes %ProgramData%\Package Cache\guid and all of it's contents if it exists. (where guid = what is in parameterinfo.xml for  Registration Id="{4C9C8A65-1159-414A-96D0-1815992D0A7F}") i.e.: C:\ProgramData\{4C9C8A65-1159-414A-96D0-1815992D0A7F}\setup.exe
        /// </summary>
        public void DeleteEngineCache()
        {
            if (!String.IsNullOrEmpty(this.RegistrationId))
            {
                // Delete the per-machine cached engine folder if it exists
                // per-machine installs need to be deleted from %ProgramData%\\Package Cache\\RegistrationId
                string cacheFolder = System.Environment.ExpandEnvironmentVariables("%ProgramData%\\Package Cache\\" + RegistrationId);
                WixTest.Burn.LayoutManager.LayoutManager.RemoveDirectory(cacheFolder);

                // Delete the per-user cached engine folder(s) if they exist (for all users)
                // per-user installs need to be deleted from %LOCALAPPDATA%\\Package Cache\\RegistrationId
                foreach (string directory in UserUtilities.GetAllUserLocalAppDataPaths())
                {
                    // delete the cache for all the other users non-admin user (normal user)
                    cacheFolder = Path.Combine(directory, "Package Cache\\" + RegistrationId);
                    WixTest.Burn.LayoutManager.LayoutManager.RemoveDirectory(cacheFolder);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Removes the payload cache for all items in the layout.  Be sure to uninstall all the payload before removing the payload cache as it might be needed during uninstall.
        /// </summary>
        public void DeletePayloadCache()
        {
            // Files are cached in:
            // EXE:  // %ProgramData%\Package Cache\filehash\filename.exe
            // MSI:  // %ProgramData%\Package Cache\productCode_version\filename.msi
            // MSP:  // %ProgramData%\Package Cache\packageCode\filename.msp

            List <string> cacheRootFolders = new List <string>();

            // delete payload cache for each item from both per-machine and per-user caches
            string cacheRootFolderPerMachine = Path.Combine("%ProgramData%", "Package Cache");

            cacheRootFolders.Add(System.Environment.ExpandEnvironmentVariables(cacheRootFolderPerMachine));

            foreach (string directory in UserUtilities.GetAllUserLocalAppDataPaths())
            {
                // delete the cache for all the other users non-admin user (normal user)
                string cacheRootFolderPerUser = Path.Combine(directory, "Package Cache");
                cacheRootFolders.Add(cacheRootFolderPerUser);
            }

            foreach (OM.WixAuthoringOM.Bundle.Chain.Package package in m_Layout.Wix.Bundle.Chain.Packages)
            {
                string packageCacheFoldername = null;
                if (!String.IsNullOrEmpty(package.CacheId))
                {
                    packageCacheFoldername = package.CacheId;

                    foreach (string cacheRootFolder in cacheRootFolders)
                    {
                        string fullPackageCachePath = Path.Combine(cacheRootFolder, packageCacheFoldername);
                        WixTest.Burn.LayoutManager.LayoutManager.RemoveDirectory(fullPackageCachePath);
                    }
                }
                else
                {
                    // TODO handle cases where CacheId is not defined.  Currently all tests are setting this.
                }
            }
        }