2011-06-10 5 views
1

msbuild 열 래퍼를 사용하여 웹 사이트 설치 프로그램의 구성 요소 목록을 생성하고 해당 트리 깊숙한 폴더에 대한 사용 권한을 정의하는 방법을 파악하려고합니다. 내 생성 WXS에서WiX 권한 - 기존 디렉토리에 대한 사용 권한 설정

그래서 때마다 내 변경을 풀 것 내가

<Directory Id="dirC092054A3A348CC48B696FD466A89A2F" Name="ExportFiles"> 
<Component Id="cmp699347B0054EDD7DD7B0935D39A66FAE" Guid="{5037..}"> 
    <File Id="..." KeyPath="yes" Source="SourceDir\Reports\ExportFiles\donotdelete.txt" /> 
</Component> 
</Directory> 

있어 그리고 내가 여기 CreateFolder를 허가 요소를 사용할 수 있습니다 실현하지만,이 파일은 사전 빌드에 재생되는 파일 . 내 주요 Product.wxs 파일 내에서 ExportFiles 폴더에 대한 사용 권한을 설정 했습니까?

+1

솔루션은 XCACLS를 사용자 지정 작업으로 사용하고 있습니다. http://support.microsoft.com/kb/318754 이렇게하면 ID를 사용하는 대신 경로에 대한 사용 권한을 설정할 수 있습니다. –

답변

0

사용자 지정 동작을 만든 다음 해당 폴더에 대한 사용 권한을 설정하십시오. 이 코드 사용

string directory = session["PATH"] + "Temp"; 
if (Directory.Exists(directory)) 
{ 
    DirectoryInfo dInfo = new DirectoryInfo(directory); 
    DirectorySecurity dSecurity = dInfo.GetAccessControl(); 
    dSecurity.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, 
      InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, 
      AccessControlType.Allow)); 
    dInfo.SetAccessControl(dSecurity); 
} 

이 코드는 폴더를 모든 사람에게 공유합니다.

+0

이 방법이 효과적이지만 아래에 설명 된 솔루션을 사용하게되었습니다. –

1

Sunil의 답변이 효과가 있지만 공유 할 수있는 다른 방법을 찾았습니다.

<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" /> 

  • 첫째 : 나는 heat.exe 내 웹 응용 프로그램의 단계적 출력을 잡아 얻을 수 here을 설명 된 기술을 사용하지만, 수정의 부부와 함께 해요

    복사 작업은 적절하게 변형 된 web.config를 잡았습니다. 자체적으로 발생하지 않는 것으로 보입니다 (나는 단계별 설정 파일에서 토큰을 얻고있었습니다).

  • 나는 WXS 파일에 XSLT를 통해 변환 임시 XML 파일에 대한 열 작업 출력,

    은을 heres 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> 

후 : 사물과 I를하는

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

그것의 아주 좋은 방법을 이미 몇 가지 다른 일을하기 위해 동일한 기술을 사용했습니다. 다른 사람도 유용하다는 것을 알기를 바랍니다.