Wix Components Xml Tool

因为要做wix安装包,要一行一行copy Components的xml描述太麻烦了,个人有点懒,不愿重复劳动;所以写了个小工具;来生成xml;原来一个小时的工作,因为有了小工具,一秒就搞定,何乐而不为?

            FolderBrowserDialog dlg = new FolderBrowserDialog();
            DialogResult ret = dlg.ShowDialog();
            if (ret == DialogResult.OK)
            {
                textBox1.Text = dlg.SelectedPath;
            }

 

 

 XmlDocument doc = new XmlDocument();
            DirectoryInfo rootDir = new DirectoryInfo(this.textBox1.Text.Trim());
            int i = 1;
            XmlElement rootElement = doc.CreateElement("Components");
            doc.AppendChild(rootElement);
            foreach (FileInfo fi in rootDir.GetFiles())
            {
                XmlElement element = doc.CreateElement("Component");
                XmlAttribute xaDir = doc.CreateAttribute("Directory");
                xaDir.Value = "VHSoft.VHSyndesignServer.DwgFunc";
                element.Attributes.Append(xaDir);
                XmlAttribute xaGuid = doc.CreateAttribute("Guid");
                xaGuid.Value = Guid.NewGuid().ToString();
                element.Attributes.Append(xaGuid);
                rootElement.AppendChild(element);

                XmlElement childElement = doc.CreateElement("File");
                XmlAttribute xaId = doc.CreateAttribute("Id");
                string ki = "00" + i.ToString();
                string Id = string.Format("SynDsn..003.{0}", ki.Substring(ki.Length - 3, 3));
                xaId.Value = Id;
                childElement.Attributes.Append(xaId);
                XmlAttribute xaName = doc.CreateAttribute("Name");
                xaName.Value = fi.Name;
                childElement.Attributes.Append(xaName);
                XmlAttribute xaKeyPath = doc.CreateAttribute("KeyPath");
                xaKeyPath.Value = "yes";
                childElement.Attributes.Append(xaKeyPath);
                XmlAttribute xaSrc = doc.CreateAttribute("Source");
                string src = string.Format(@"VHSyndesignServer_32\DwgFunc\{0}", fi.Name);
                xaSrc.Value = src;
                childElement.Attributes.Append(xaSrc);
                element.AppendChild(childElement);
                i++;
            }
            doc.Save(@"c:\Components.xml");


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值