Exemple #1
0
        public void DoJob()
        {
            Ngen ngen = new Ngen();

            OnProgressChanged(new ProgressArgs(1, "正在执行Ngen项目(可能需要几分钟)...", continiousProgress: true));
            ngen.ExecuteQueue();
            OnProgressChanged(new ProgressArgs(50, "正在搜索未生成的本机映像...", continiousProgress: true));
            string[] array = ngen.Display("DevExpress.");
            OnProgressChanged(new ProgressArgs(100, $"{array.Length} 找到本机映像. 准备卸载..."));
            Thread.Sleep(1000);
            int num = 0;

            string[] array2 = array;
            foreach (string assembly in array2)
            {
                num++;
                ngen.Uninstall(assembly);
                OnProgressChanged(new ProgressArgs(100 * num / array.Length, $"本机映像 {num} 的 {array.Length} 已卸载."));
            }
            OnProgressChanged(new ProgressArgs(100, "所有操作完成."));
        }
        private Dictionary <PackageItem, WixItem> ProcessIntermediates(IEnumerable <Intermediate> intermediates)
        {
            Dictionary <PackageItem, WixItem> wixItems = new Dictionary <PackageItem, WixItem>();

            foreach (Intermediate intermediate in intermediates)
            {
                foreach (PackageItem item in intermediate.Items)
                {
                    File file = item as File;
                    if (file != null)
                    {
                        WixFile msiFile = new WixFile(this, file);
                        wixItems.Add(file, msiFile);

                        NgenPackageItem ngen;
                        if (Ngen.TryGetPackageItem(file, out ngen))
                        {
                            ngen.LineNumber = file.LineNumber;
                            file.Items.Add(ngen);

                            WixNativeImage nativeImage = new WixNativeImage(this, ngen);
                            wixItems.Add(ngen, nativeImage);
                        }
                    }
                    else
                    {
                        Folder folder = item as Folder;
                        if (folder != null)
                        {
                            if (folder.External)
                            {
                                WixFolderReference msiFolderRef = new WixFolderReference(this, folder);
                                wixItems.Add(folder, msiFolderRef);
                            }
                            else
                            {
                                WixFolder msiFolder = new WixFolder(this, folder);
                                wixItems.Add(folder, msiFolder);
                            }
                        }
                        else
                        {
                            InprocServer inprocServer = item as InprocServer;
                            if (null != inprocServer)
                            {
                                WixClassId classId = new WixClassId(this, inprocServer);
                                wixItems.Add(inprocServer, classId);
                            }
                            else
                            {
                                OutprocServer outprocServer = item as OutprocServer;
                                if (null != outprocServer)
                                {
                                    WixClassId classId = new WixClassId(this, outprocServer);
                                    wixItems.Add(outprocServer, classId);
                                }
                                else
                                {
                                    Property property = item as Property;
                                    if (property != null)
                                    {
                                        WixProperty prop = new WixProperty(this, property);
                                        wixItems.Add(property, prop);
                                    }
                                    else
                                    {
                                        FileSearch fileSearch = item as FileSearch;
                                        if (fileSearch != null)
                                        {
                                            WixFileSearch fs = new WixFileSearch(this, fileSearch);
                                            wixItems.Add(fileSearch, fs);
                                        }
                                        else
                                        {
                                            Group group = item as Group;
                                            if (group != null)
                                            {
                                                WixGroup msiGroup = new WixGroup(this, group);
                                                wixItems.Add(group, msiGroup);
                                            }
                                            else if (item is Package)
                                            {
                                                // TODO: send an error message since library files cannot process Package elements.
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Fix up all the item parents and groups now that we have them
            // all processed into a single look up dictionary.
            foreach (var kv in wixItems)
            {
                PackageItem pi = kv.Key;
                WixItem     wi = kv.Value;
                if (pi.Parent != null)
                {
                    wi.Parent = wixItems[pi.Parent];
                }

                if (pi.Group != null)
                {
                    wi.Group = (WixGroup)wixItems[pi.Group];
                    wi.Group.ContainedWixItems.Add(wi);
                }
            }

            return(wixItems);
        }