尽管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