有一些文件需要从.WXS基于给定的dev,prod等环境输入中删除,它将作为属性传递给Heat.exe。基于此,我需要在通过XSLT转换收获后从Fragment.WXS中过滤掉或删除一些文件。例如,如果xslt模板是dev,那么我需要所有源文件不包含.UAT,.Prod,.Test的文件。我还需要使用Heat来执行转换所需的命令。
请参阅下面的热量输出
中的一些组件<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Directory Id="dir8EF11DA0EAFBFCB7A0B81343D3750C8B" Name="SCBUDirect" />
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="SCBUDirect">
<Component Id="cmpE3B75974B57E1263C93B9B05FDFE715F" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{CA810124-F44B-4EF5-986A-07FAA67434AB}">
<File Id="fil85729F855FDD131D6161043C08CB4543" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\TestBuild_dev_ConnectionStrings.config" />
</Component>
<Component Id="cmpERG5974B57E1263C93B9B05FDFE715F" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{ERGT50124-F44B-4EF5-986A-07FAA67434AB}">
<File Id="fil8574324425555FDD131D6161043C08CB4543" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\TestBuild_prod_ConnectionStrings.config" />
</Component>
<Component Id="cmp51A6C4030B563BC4A64DA99AED42D978" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{CF063EF0-6926-4D21-B89D-BD71E0E926F7}">
<File Id="fil1494493122AA1F38F8D2C11F93A8D4E8" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment.config" />
</Component>
<Component Id="cmpDF354EF7DC6C98108D05886911231011" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{F912A8C7-1226-49D6-897F-1878A1607B16}">
<File Id="fil1058EF5A5E46590311096FFC704CD243" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\basic.log4net.dev" />
</Component>
<Component Id="cmpD84FEB6CD3B1AE3534AA6B94CF5065C8" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{8BEBA112-9967-4DD9-96FC-25A879C5D6FA}">
<File Id="filE0D63A4EC6CCCF6E9C06A91E04EA87E7" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\basic.log4net.prod" />
</Component>
<Component Id="cmp0B6A1EF1380A825CC1F3894FAA38CC0B" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{60C807BD-142C-4C1F-8366-DC297657AB0A}">
<File Id="fil20F28B0827462F414C432783951DD049" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\basic.log4net.test" />
</Component>
<Component Id="cmp80CFA73AA353BE789D4539008E7F3516" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{0B3FA0E7-8F66-408C-944F-DAA0A847B6C4}">
<File Id="fil2B292A388045FDF49475C9F6C5D144D1" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\basic.log4net.uat" />
</Component>
<Component Id="cmpE1C2EEC551696DCE99C2CAB9ED013C54" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{A3D766EE-A488-468A-A7BF-DDB507B21299}">
<File Id="fil2F90622E603C0AF703A504C3DE3A6201" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.Dev.config" />
</Component>
<Component Id="cmpEBF2150BC59E378124B87AF387DA5519" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{16CF5D16-A551-4184-9E9D-772A9277941A}">
<File Id="fil9241DCC3F781240AD979AAF25BF020F5" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.Dev.CSR.config" />
</Component>
<Component Id="cmpA8F307EAB3BEB1352C23666A8E11D981" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{3A42EC95-3DE5-4BB8-870F-E4AE8C8B1AE0}">
<File Id="fil8A99AE4CB701995838FD078019546D30" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.Prod.config.xml" />
</Component>
<Component Id="cmpB64314E8A44B127FAE8A6CBAAF9AA052" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{450B216D-7A3D-40EF-A41D-AAB2FA65BC5D}">
<File Id="fil0F1FCF642AF4B0D8A101964BCAFCA227" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.Prod.CSR.config.xml" />
</Component>
<Component Id="cmpD59E44F90B1003A9D3FEEE194F8AA63D" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{94AA1663-5043-4DA1-A60D-50FFEDED6B7A}">
<File Id="filCA238418D1A725B1303D44003BEE495E" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.Test.config.xml" />
</Component>
<Component Id="cmp1AF2C8707EBD76A179C1CE20515E0A9B" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{42342DFE-227C-4F70-B2E9-B9422DEA45AE}">
<File Id="filAB15496223BAA05CC1CCFED05F52E902" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.Test.CSR.config.xml" />
</Component>
<Component Id="cmp89433C61AF95511BE1BC8121DAAAA401" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{DDB6E815-9946-4744-8D1A-E4BE3D09EC2E}">
<File Id="filC0041C051A21C3705C9417015F51ACCC" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.UAT.config.xml" />
</Component>
<Component Id="cmp131FA57DB66446A7226E0236B8ACAAFD" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{6CA4CE62-33FD-4BF9-8E43-1A079983D492}">
<File Id="fil42A0BC81342E575F8EA9F004A065CCA4" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.UAT.CSR.config.xml" />
</Component>
<Component Id="cmp3B36FD232E0AAD653B9259D5F2AC60A2" Directory="dirE4970414C520BB64F468385DC180508F" Guid="{BF4A808E-AFBD-4F43-8F90-20E38639C8BD}">
<File Id="filFD59C7E39C8BCA47D7ECEA7EBCA4E8FF" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\controls\ReferAFriend\ReferAFriendInfo.ascx" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<DirectoryRef Id="dir19836A556979704BCD883A1A4BC5ACCA">
<Directory Id="dir64C5FB989D956FBA878D608B754DE28A" Name="App_Config" />
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="dir64C5FB989D956FBA878D608B754DE28A">
<Directory Id="dir83BD7C94126520DBEDF76AF461521286" Name="Deployment" />
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="dir0370A1E873AC03CA5FA01FB090FBCEF4">
<Directory Id="dirE4970414C520BB64F468385DC180508F" Name="ReferAFriend" />
</DirectoryRef>
</Fragment>
</Wix>
这是我的xslt文件已经提出需要使用。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<!--<!–Identity Transform–>-->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!--<!–Set up keys for ignoring various file types–>-->
<xsl:key name="config-search" match="wix:Component[contains(wix:File/@Source, 'TestBuild_prod')]" use="@Id"/>
<!--<!–Match and ignore TestBuild_prod files for dev Environment similarly vice-versa for prod Environment –>-->
<xsl:template match="wix:Component[key('config-search', @Id)]"/>
<xsl:template match="wix:ComponentRef[key('config-search', @Id)]"/>
</xsl:stylesheet>
转换后,如果输入为“dev”
,则fragment.WXS文件如下所示<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Directory Id="dir8EF11DA0EAFBFCB7A0B81343D3750C8B" Name="SCBUDirect" />
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="SCBUDirect">
<Component Id="cmpE3B75974B57E1263C93B9B05FDFE715F" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{CA810124-F44B-4EF5-986A-07FAA67434AB}">
<File Id="fil85729F855FDD131D6161043C08CB4543" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\TestBuild_dev_ConnectionStrings.config" />
</Component>
<Component Id="cmp51A6C4030B563BC4A64DA99AED42D978" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{CF063EF0-6926-4D21-B89D-BD71E0E926F7}">
<File Id="fil1494493122AA1F38F8D2C11F93A8D4E8" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment.config" />
</Component>
<Component Id="cmpDF354EF7DC6C98108D05886911231011" Directory="dir64C5FB989D956FBA878D608B754DE28A" Guid="{F912A8C7-1226-49D6-897F-1878A1607B16}">
<File Id="fil1058EF5A5E46590311096FFC704CD243" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\basic.log4net.dev" />
</Component>
<Component Id="cmpE1C2EEC551696DCE99C2CAB9ED013C54" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{A3D766EE-A488-468A-A7BF-DDB507B21299}">
<File Id="fil2F90622E603C0AF703A504C3DE3A6201" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.Dev.config" />
</Component>
<Component Id="cmpEBF2150BC59E378124B87AF387DA5519" Directory="dir83BD7C94126520DBEDF76AF461521286" Guid="{16CF5D16-A551-4184-9E9D-772A9277941A}">
<File Id="fil9241DCC3F781240AD979AAF25BF020F5" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\Deployment\Deployment.Dev.CSR.config" />
</Component>
<Component Id="cmp3B36FD232E0AAD653B9259D5F2AC60A2" Directory="dirE4970414C520BB64F468385DC180508F" Guid="{BF4A808E-AFBD-4F43-8F90-20E38639C8BD}">
<File Id="filFD59C7E39C8BCA47D7ECEA7EBCA4E8FF" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\controls\ReferAFriend\ReferAFriendInfo.ascx" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<DirectoryRef Id="dir19836A556979704BCD883A1A4BC5ACCA">
<Directory Id="dir64C5FB989D956FBA878D608B754DE28A" Name="App_Config" />
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="dir64C5FB989D956FBA878D608B754DE28A">
<Directory Id="dir83BD7C94126520DBEDF76AF461521286" Name="Deployment" />
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="dir0370A1E873AC03CA5FA01FB090FBCEF4">
<Directory Id="dirE4970414C520BB64F468385DC180508F" Name="ReferAFriend" />
</DirectoryRef>
</Fragment>
</Wix>