儘管Sunil的答案確實有效,但我發現了另一種我認爲會分享的方式。
我使用概述here獲得heat.exe搶我的web應用程序的調試輸出的技術,但一對夫婦的修改:
<Target Name="BeforeBuild">
<MSBuild Projects="%(ProjectReference.FullPath)" Targets="Package" Properties="Configuration=$(Configuration);Platform=AnyCPU" Condition="'%(ProjectReference.WebProject)'=='True'" />
<Copy SourceFiles="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\TransformWebConfig\transformed\web.config" OverwriteReadOnlyFiles="true" DestinationFolder="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\" />
<PropertyGroup>
<LinkerBaseInputPaths>%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\</LinkerBaseInputPaths>
</PropertyGroup>
<HeatDirectory OutputFile="%(ProjectReference.Filename)-temp.xml" Directory="%(ProjectReference.RootDir)%(ProjectReference.Directory)obj\$(Configuration)\Package\PackageTmp\" DirectoryRefId="INSTALLLOCATION" ComponentGroupName="%(ProjectReference.Filename)_Project" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutoGenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" Condition="'%(ProjectReference.WebProject)'=='True'" />
<XslTransformation XmlInputPaths="%(ProjectReference.Filename)-temp.xml" XslInputPath="XslTransform.xslt" OutputPaths="%(ProjectReference.Filename).wxs" />
繼承人的XSLT被拾起:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
<xsl:template match="w:Directory[@Name='ExportFiles']/w:Component">
<w:Component>
<xsl:attribute name="Id">
<xsl:value-of select="@Id"/>
</xsl:attribute>
<xsl:attribute name="Guid">
<xsl:value-of select="@Guid"/>
</xsl:attribute>
<w:CreateFolder>
<w:Permission User="Administrators" GenericAll="yes" />
<w:Permission User="Network Service" GenericAll="yes" />
</w:CreateFolder>
<xsl:apply-templates select="*" />
</w:Component>
它只是簡單地再現與具有添加的權限位的ExportFiles文件夾以外的文件: 之前:
<Directory Id="dirC092054A3A348CC48B696FD466A89A2F" Name="ExportFiles">
<Component Id="cmp699347B0054EDD7DD7B0935D39A66FAE" Guid="{87D70A4F-A757-41C2-8AC9-E2904479FD45}">
<File Id="filEC20935A3F97F24E20E1C2041AC766CA" KeyPath="yes" Source="SourceDir\Reports\ExportFiles\donotdelete.txt" />
</Component>
</Directory>
後:
<Directory Id="dirC092054A3A348CC48B696FD466A89A2F" Name="ExportFiles">
<w:Component Id="cmp699347B0054EDD7DD7B0935D39A66FAE" Guid="{87D70A4F-A757-41C2-8AC9-E2904479FD45}"
xmlns:w="http://schemas.microsoft.com/wix/2006/wi">
<w:CreateFolder>
<w:Permission User="Administrators" GenericAll="yes" />
<w:Permission User="Network Service" GenericAll="yes" />
</w:CreateFolder>
<File Id="filEC20935A3F97F24E20E1C2041AC766CA" KeyPath="yes" Source="SourceDir\Reports\ExportFiles\donotdelete.txt" />
</w:Component>
</Directory>
其相當做的事情,我的一個很好的方式已經使用相同的技術來做其他一些事情。希望別人也能找到它有用。
解決方案使用XCACLS作爲自定義操作:http://support.microsoft.com/kb/318754。這樣您就可以在路徑上設置權限而不是使用ID。 – 2011-06-10 13:46:48