我有一个安装程序需要明确是一个 PerUser msi。当前的问题是使用 Heat 获取文件并没有提供一种方法来生成完全符合 PerUser 包的组件。特别是 ICE64“目录 dir7956CF617C38D877C93B5A7D33313596 在用户配置文件中,但未在 RemoveFile 表中列出。
现在,只要我知道结构,这就不是问题,因为我可以创建一个包含所有目录的组件并将其包含在功能中。 但是,如果结构发生变化,则需要手动查找所有目录并手动添加它们。这消除了其他开发人员自由添加/删除文件的灵 active 。
对于那些感兴趣的人,这里是我使用的热命令:
heat.exe dir "SourceDir"-dr INSTALLDIR -cg CG_Binaries -nologo -gg -g1 -sfrag -srd -svb6 -scom -sreg -var "var.Binaries"-out "Binaries.wxs"'/>
这是 heat.exe 未经任何转换生成的原始 XML:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLDIR">
<Directory Id="dir7956CF617C38D877C93B5A7D33313596" Name="Folder1">
<Component Id="cmp1CBAE345A14FB4F0343E1FC307F5EE1D" Guid="CBB5AF6A-D0A2-464D-BFAA-49F9C102A4F4">
<File Id="filB5C5E94E5D59CC7DB489F6823F341316" KeyPath="yes" Source="$(var.Binaries)\Folder1\NewTextFile0.txt" />
</Component>
</Directory>
<Directory Id="dir2BA1778353CDCC6DE102110034297AC9" Name="Folder2">
<Component Id="cmp55726990D3629FC63F840780B5BC7729" Guid="49CAB541-CEB5-423B-89E2-A42D51AD9E7E">
<File Id="fil98449FB9E91E1F95E2BA0E6AD712D2E6" KeyPath="yes" Source="$(var.Binaries)\Folder2\NewTextFile1.txt" />
</Component>
<Directory Id="dir52EB3739C4D4F7DFB9D67E41E7687374" Name="Folder3">
<Component Id="cmpEC9C0276E68BB6794098A24DCF44E0BD" Guid="B495A9DB-3449-45CC-9197-6FD9C8C29C72">
<File Id="filB96F911B8B2DE84CED663406AD87D508" KeyPath="yes" Source="$(var.Binaries)\Folder2\Folder3\NewTextFile4.txt" />
</Component>
<Component Id="cmp873EC3B1583A11ED180C2B5A55082E5E" Guid="B9C57A66-DF0A-480D-83E6-C8E7624974BD">
<File Id="fil48004A44BAD8605014735C6A3D6F7004" KeyPath="yes" Source="$(var.Binaries)\Folder2\Folder3\NewTextFile5.txt" />
</Component>
<Component Id="cmp1614194F7F0694F7AC043F7778BA8109" Guid="B9807535-AC38-41B3-AD9E-A5EB58AC6E12">
<File Id="filF11AF0F827CF7E0D02F918F3FD7502AC" KeyPath="yes" Source="$(var.Binaries)\Folder2\Folder3\NewTextFile6.txt" />
</Component>
</Directory>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_Binaries">
<ComponentRef Id="cmp1CBAE345A14FB4F0343E1FC307F5EE1D" />
<ComponentRef Id="cmp55726990D3629FC63F840780B5BC7729" />
<ComponentRef Id="cmpEC9C0276E68BB6794098A24DCF44E0BD" />
<ComponentRef Id="cmp873EC3B1583A11ED180C2B5A55082E5E" />
<ComponentRef Id="cmp1614194F7F0694F7AC043F7778BA8109" />
</ComponentGroup>
</Fragment>
</Wix>
我有一个 XSL 将 File 的 KeyPath 属性更改为 no 以符合 ICE38 并添加 RegistryValue 以修复没有为 File 设置 KeyPaths 时的错误。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns="http://schemas.microsoft.com/wix/2006/wi"
exclude-result-prefixes="xsl wix">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!--File keypath to no and add registry keypath-->
<xsl:template match="wix:Component/wix:File[@Id]">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:attribute name="KeyPath">
<xsl:text>no</xsl:text>
</xsl:attribute>
</xsl:copy>
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</xsl:template>
<xsl:template match="wix:Component/wix:File[not(@Id)]">
<xsl:copy>
<xsl:apply-templates select="@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
这是期望的输出
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLDIR">
<Component Id="SomeName" Guid="A99D16EF-80A3-4C98-A91D-3E95C7BD98AE">
<RemoveFolder Id="dir7956CF617C38D877C93B5A7D33313596" Directory="dir7956CF617C38D877C93B5A7D33313596" On="uninstall" />
<RemoveFolder Id="dir2BA1778353CDCC6DE102110034297AC9" Directory="dir2BA1778353CDCC6DE102110034297AC9" On="uninstall"/>
<RemoveFolder Id="dir52EB3739C4D4F7DFB9D67E41E7687374" Directory="dir52EB3739C4D4F7DFB9D67E41E7687374" On="uninstall"/>
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
<Directory Id="dir7956CF617C38D877C93B5A7D33313596" Name="Folder1">
<Component Id="cmp1CBAE345A14FB4F0343E1FC307F5EE1D" Guid="CBB5AF6A-D0A2-464D-BFAA-49F9C102A4F4">
<File Id="filB5C5E94E5D59CC7DB489F6823F341316" KeyPath="no" Source="$(var.Binaries)\Folder1\NewTextFile0.txt" />
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</Directory>
<Directory Id="dir2BA1778353CDCC6DE102110034297AC9" Name="Folder2">
<Component Id="cmp55726990D3629FC63F840780B5BC7729" Guid="49CAB541-CEB5-423B-89E2-A42D51AD9E7E">
<File Id="fil98449FB9E91E1F95E2BA0E6AD712D2E6" KeyPath="no" Source="$(var.Binaries)\Folder2\NewTextFile1.txt" />
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
<Directory Id="dir52EB3739C4D4F7DFB9D67E41E7687374" Name="Folder3">
<Component Id="cmpEC9C0276E68BB6794098A24DCF44E0BD" Guid="B495A9DB-3449-45CC-9197-6FD9C8C29C72">
<File Id="filB96F911B8B2DE84CED663406AD87D508" KeyPath="no" Source="$(var.Binaries)\Folder2\Folder3\NewTextFile4.txt" />
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
<Component Id="cmp873EC3B1583A11ED180C2B5A55082E5E" Guid="B9C57A66-DF0A-480D-83E6-C8E7624974BD">
<File Id="fil48004A44BAD8605014735C6A3D6F7004" KeyPath="no" Source="$(var.Binaries)\Folder2\Folder3\NewTextFile5.txt" />
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
<Component Id="cmp1614194F7F0694F7AC043F7778BA8109" Guid="B9807535-AC38-41B3-AD9E-A5EB58AC6E12">
<File Id="filF11AF0F827CF7E0D02F918F3FD7502AC" KeyPath="no" Source="$(var.Binaries)\Folder2\Folder3\NewTextFile6.txt" />
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="CG_Binaries">
<ComponentRef Id="SomeName"/>
<ComponentRef Id="cmp1CBAE345A14FB4F0343E1FC307F5EE1D" />
<ComponentRef Id="cmp55726990D3629FC63F840780B5BC7729" />
<ComponentRef Id="cmpEC9C0276E68BB6794098A24DCF44E0BD" />
<ComponentRef Id="cmp873EC3B1583A11ED180C2B5A55082E5E" />
<ComponentRef Id="cmp1614194F7F0694F7AC043F7778BA8109" />
</ComponentGroup>
</Fragment>
</Wix>
所以我想要实现的是让转换器循环遍历 xml,找到目录元素的所有 ID 并创建一个新元素,如下所示:
<Component Id="SomeName" Guid="A99D16EF-80A3-4C98-A91D-3E95C7BD98AE">
<RemoveFolder Id="dir7956CF617C38D877C93B5A7D33313596" Directory="dir7956CF617C38D877C93B5A7D33313596" On="uninstall" />
<RemoveFolder Id="dir2BA1778353CDCC6DE102110034297AC9" Directory="dir2BA1778353CDCC6DE102110034297AC9" On="uninstall"/>
<RemoveFolder Id="dir52EB3739C4D4F7DFB9D67E41E7687374" Directory="dir52EB3739C4D4F7DFB9D67E41E7687374" On="uninstall"/>
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
我做了一些尝试来实现这一目标,但惨遭失败。我们将不胜感激。
最佳答案
从您所期望的外观来看,您需要做的就是一个包含 DirectoryRef 元素的模板...
<xsl:template match="wix:DirectoryRef[@Id='INSTALLDIR']">
然后您可以使用 xsl:for-each 构造选择所有 Directory 元素
<xsl:for-each select=".//wix:Directory[wix:Component/wix:File[@Id]]">
<RemoveFolder Id="{@Id}" Directory="{@Id}" On="uninstall" />
</xsl:for-each>
试试这个 XSLT(我硬编码了 Guid 属性,因为您需要为此使用某种扩展函数)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns="http://schemas.microsoft.com/wix/2006/wi"
exclude-result-prefixes="xsl wix">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="wix:DirectoryRef[@Id='INSTALLDIR']">
<xsl:copy>
<xsl:apply-templates select="@*" />
<Component Id="SomeName" Guid="A99D16EF-80A3-4C98-A91D-3E95C7BD98AE">
<xsl:for-each select=".//wix:Directory[wix:Component/wix:File[@Id]]">
<RemoveFolder Id="{@Id}" Directory="{@Id}" On="uninstall" />
</xsl:for-each>
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<!--File keypath to no and add registry keypath-->
<xsl:template match="wix:Component/wix:File[@Id]">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:attribute name="KeyPath">
<xsl:text>no</xsl:text>
</xsl:attribute>
</xsl:copy>
<RegistryValue Root="HKCU" Key="!(wix.RegKeyLocation)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</xsl:template>
</xsl:stylesheet>
关于xml - 收集用于 PerUser 安装程序的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35848336/
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
我试图在一个项目中使用rake,如果我把所有东西都放到Rakefile中,它会很大并且很难读取/找到东西,所以我试着将每个命名空间放在lib/rake中它自己的文件中,我添加了这个到我的rake文件的顶部:Dir['#{File.dirname(__FILE__)}/lib/rake/*.rake'].map{|f|requiref}它加载文件没问题,但没有任务。我现在只有一个.rake文件作为测试,名为“servers.rake”,它看起来像这样:namespace:serverdotask:testdoputs"test"endend所以当我运行rakeserver:testid时
我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
Rails2.3可以选择随时使用RouteSet#add_configuration_file添加更多路由。是否可以在Rails3项目中做同样的事情? 最佳答案 在config/application.rb中:config.paths.config.routes在Rails3.2(也可能是Rails3.1)中,使用:config.paths["config/routes"] 关于ruby-on-rails-Rails3中的多个路由文件,我们在StackOverflow上找到一个类似的问题
对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack