Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Permissions Wix:CustomAction设置文件夹权限_Permissions_Directory_Wix_Custom Action_Create Directory - Fatal编程技术网

Permissions Wix:CustomAction设置文件夹权限

Permissions Wix:CustomAction设置文件夹权限,permissions,directory,wix,custom-action,create-directory,Permissions,Directory,Wix,Custom Action,Create Directory,我们正在使用WiX将ASP.NET代码捆绑到MSI安装程序中,需要将[ComputerName]\IIS\U WPG组设置为对安装目录下的文件夹(名为“CO”)具有修改权限。安装后目录结构如下所示 C:\inetpub\wwwroot\MyApp\CO CO文件夹实际上是.NET解决方案文件的一部分,当应用程序捆绑到MSI中时,会自动包含CO文件夹,因为它下面有标记为“内容”的XML文件(这意味着我不需要显式使用CreateFolder在MyApp下面创建CO文件夹)。这些XML文件由应用程序

我们正在使用WiX将ASP.NET代码捆绑到MSI安装程序中,需要将[ComputerName]\IIS\U WPG组设置为对安装目录下的文件夹(名为“CO”)具有修改权限。安装后目录结构如下所示

C:\inetpub\wwwroot\MyApp\CO
CO文件夹实际上是.NET解决方案文件的一部分,当应用程序捆绑到MSI中时,会自动包含CO文件夹,因为它下面有标记为“内容”的XML文件(这意味着我不需要显式使用CreateFolder在MyApp下面创建CO文件夹)。这些XML文件由应用程序更新,这就是IIS\U WPG需要修改权限的原因

我的问题是,如何设置CO文件夹的权限?我想我可以创建文件夹,试图覆盖默认包含的任何权限,但它没有设置权限-我猜这是因为我创建的文件夹被MSI中的实际文件夹覆盖,从而覆盖了我设置的权限

我想我可能需要创建一个CustomAction,它在InstallFinalize之前的某个时候执行,但是我迷路了,因为我不知道如何将文件夹创建链接到CustomAction。我试过这个

<InstallExecuteSequence>
    <Custom Action="SetPermission" Before="InstallFinalize" />    
</InstallExecuteSequence>
<CustomAction Id="SetPermission" Directory="CODIRECTORY">
    <Directory Id="CODIRECTORY" Name="CO" LongName="CO">
        <Component Id="CODIR" Guid="D28C9DA4-D20F-45E6-9C9B-4687177EDF41" DiskId="1">
            <CreateFolder>
                <Permission GenericAll="yes" User="[ComputerName]\IIS_WPG" />
                <Permission GenericAll="yes" User="Administrators" />
                <Permission GenericRead="yes" GenericWrite="yes" User="ASPNET" />
            </CreateFolder>
        </Component>
    </Directory>      
</CustomAction>
我也尝试过使用PermissionEx,但在使用它时出现了这个错误

error CNDL0005 : The CreateFolder element contains an unexpected child element 'util:PermissionEx'.
即使我添加了xmlns:util=”http://schemas.microsoft.com/wix/UtilExtension“在文件的顶部


如何使CustomAction正常工作并正确设置文件夹权限?

您的设置与我的设置非常相似,但差别不大

我们不在自定义操作中设置权限,而是通过创建目录来设置权限

这一款适合我们:

<Directory Name="SourceDir" Id="TARGETDIR"> 
  <Directory Id="CommonAppDataFolder"> 
    <Directory Name="$(var.InstallCompany)" Id="CompanyDir"> 
      <Directory Name="$(var.InstallProduct)" Id="ProductDir"> 
        <Directory Name="$(var.InstallFolder)" Id="INSTALLLOCATION">
          <Component Id="Permission.InstallFolder" Guid="{7C5234ED-EE92-468A-A765-27E5747705DB}"> 
            <CreateFolder>
              <Permission ChangePermission="yes" GenericAll="yes" User="Administrators"/> 
              <Permission User="Everyone" WriteExtendedAttributes="yes" WriteAttributes="yes" CreateFile="yes" CreateChild="yes" GenericWrite="no" GenericRead="yes" GenericExecute="yes"/> 
            </CreateFolder> 
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </Directory>
</Directory>

我必须创建一个CustomAction,类似于本文中所做的

我知道这并不理想,但它解决了问题。我们有可能升级到WIX3并使用PermissionEx,但这是我另一天必须面对的一场战斗


不确定它是否有用,但我做了更多的调查,发现我们使用的是Wix 2,所以我猜这就是为什么我们不能使用PermissionEx。

谢谢@Max。我尝试了您上面提到的方法,但我认为该文件夹已创建,但在作为.net应用程序的一部分安装时会被覆盖,因此,我正在尝试在安装完成之前更新权限以确定是否正确。您是否尝试过类似于我的解决方案的方法?您说过,由于分配给此目录的文件,该文件夹是自动创建的。但是你没有明确地创建它?嗨,Max,谢谢你的回复。是的,我确实按照您上面指定的那样显式地使用创建了文件夹,这很好,但是我正在设置的权限正在被覆盖,所以我想在创建文件夹后,我会尝试使用自定义操作来分配它们。
<Directory Name="SourceDir" Id="TARGETDIR"> 
  <Directory Id="CommonAppDataFolder"> 
    <Directory Name="$(var.InstallCompany)" Id="CompanyDir"> 
      <Directory Name="$(var.InstallProduct)" Id="ProductDir"> 
        <Directory Name="$(var.InstallFolder)" Id="INSTALLLOCATION">
          <Component Id="Permission.InstallFolder" Guid="{7C5234ED-EE92-468A-A765-27E5747705DB}"> 
            <CreateFolder>
              <Permission ChangePermission="yes" GenericAll="yes" User="Administrators"/> 
              <Permission User="Everyone" WriteExtendedAttributes="yes" WriteAttributes="yes" CreateFile="yes" CreateChild="yes" GenericWrite="no" GenericRead="yes" GenericExecute="yes"/> 
            </CreateFolder> 
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </Directory>
</Directory>