Esempio n. 1
0
        public static void PurgeCache()
        {
            lock (_cachedExpandedFolder)
            {
                if (_cachedExpandedFolder.Count > 0)
                {
                    foreach (var valueTuple in _cachedExpandedFolder.Values)
                    {
                        string expandedFolder = valueTuple.Item1;
                        TempFileSystem.DeleteDirectorySafe(expandedFolder, recursive: true);
                    }

                    _cachedExpandedFolder.Clear();
                }
                else
                {
                    TempFileSystem.DeleteDirectorySafe(TempFileSystem.Root, recursive: true);
                }
            }
        }
Esempio n. 2
0
        public static Wix ConvertFileSystem(TempFileSystem fs, string upgradecode, string appname, string version, string icon, string manufacturer, string dialogPath, string bannerPath, string licensePath)
        {
            WixProduct prod = new WixProduct(appname, version, upgradecode);

            prod.Manufacturer = manufacturer ?? "";
            prod.AddObj(new WixPackage());
            prod.AddObj(new WixUpgrade(upgradecode, version));
            prod.AddObj(new WixMedia());

            string iconFileName = icon;

            if (iconFileName.IsNullOrEmpty())
            {
                iconFileName = SaveIconToDisk();
            }

            var iconName = Path.GetFileName(iconFileName);


            prod.AddObj(new WixIcon(iconName, iconFileName));
            prod.AddObj(new WixProperty("ARPPRODUCTICON", iconName));

            //check manufacturer and app name for valid registry names.



            //string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string appRegistryFolder = manufacturer + "\\" + appname;


            var lookupDict = new Dictionary <TempFolderObject, WixObject>();
            var wixObjects = GenerateFileSystemObjects(lookupDict, fs.Root, appRegistryFolder);

            foreach (var wixObj in wixObjects)
            {
                prod.AddObj(wixObj);
            }

            foreach (var feat in fs.Features.Values)
            {
                WixFeature wfeat = new WixFeature("_" + feat.Title, feat.Title, feat.Description);
                foreach (var comp in feat.ComponentIndex)
                {
                    var wixObj = lookupDict[comp];
                    if (wixObj is WixFile wfile)
                    {
                        wfeat.AddComponentRef(wfile.GetComponent().GetComponentRef());
                    }
                    else if (wixObj is WixDirectory wFold)
                    {
                        wfeat.AddComponentRef(wFold.GetRemovalRef());
                    }
                }
                prod.AddObj(wfeat);
            }

            //**************** UI BELOW
            prod.AddObj(new WixUIRef("WixUI_FeatureTree"));
            prod.AddObj(new WixUIRef("WixUI_ErrorProgressText"));

            prod.Objects.AddRange(UnpackUIResources(dialogPath, bannerPath, licensePath));


            Wix wix = new Wix();

            wix.AddProduct(prod);

            return(wix);
        }