Wix:CustomAction设置文件夹权限 [英] Wix: CustomAction to set Folder permissions

查看:71
本文介绍了Wix:CustomAction设置文件夹权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We're using WiX to bundle up our ASP.NET code into an MSI installer, and we need to set the [ComputerName]\IIS_WPG group to have modify permissions on a folder (named "CO") under the installation directory. The directory structure looks like this after install

C:\inetpub\wwwroot\MyApp\CO

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

The CO folder is actually part of the .NET solution file, and when the application is bundled into an MSI, the CO folder is included automatically because there are XML files underneath it which are marked as "Content" (this means that I don't need to explicitly use CreateFolder to create the CO folder underneath MyApp). These XML files are updated by the application, which is why the IIS_WPG needs modify permission.

我的问题是,如何在CO文件夹上设置权限?我认为我可能能够创建该文件夹,以尝试覆盖默认情况下包含的所有权限,但是它没有设置权限-我猜这是因为我正在创建的文件夹被其中的实际文件夹覆盖MSI,从而覆盖我设置的权限.

My question is, how do I set the permission on the CO folder? I thought that I might be able to create the folder in an attempt to overwrite whatever permissions are included by default but it doesn't set the permission - I'm guessing that's because the folder I'm creating is overwritten by the actual folder in the MSI, thereby overwriting the permissions that I've set.

我认为我可能需要创建一个CustomAction,它会在InstallFinalize之前的某个时刻执行,但是我迷路了,因为我不知道如何将文件夹创建链接到CustomAction.我已经尝试过了

I thought that I might need to create a CustomAction which gets executed at some point before InstallFinalize, but I'm lost because I don't understand how to link the folder creation to the CustomAction. I've tried this

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

但这给了我这个错误

error CNDL0049 : The CustomAction element's DllEntry, Error, ExeCommand, JScriptCall, Script, Value, or VBScriptCall attribute was not found; one of these is required.
error CNDL0005 : The CustomAction element contains an unexpected child element 'Directory'

我也尝试过使用PermissionEx,但是在使用PermissionEx时出现此错误

I've also tried to use PermissionEx, but I get this error when using that

error CNDL0005 : The CreateFolder element contains an unexpected child element 'util:PermissionEx'.

即使我在文件顶部添加了xmlns:util ="http://schemas.microsoft.com/wix/UtilExtension".

even though I added xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" at the top of the file.

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

How do I get the CustomAction to work and Folder Permissions correct?

推荐答案

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

I had to create a CustomAction, similar to what is done in this post

使用cacls设置权限

我知道这并不理想,但是可以解决问题.我们可能会升级到Wix 3并使用PermissionEx,但这是我第二天必须进行的战斗.

I know it's not ideal, but it solves the problem. We could potentially upgrade to Wix 3 and use PermissionEx, but that's a battle I'll have to fight another day.

不确定它是否有帮助,但是我进行了更多调查,发现我们正在使用Wix 2,因此我猜测这就是为什么我们不能使用PermissionEx的原因.

Not sure it helps, but I did some more investigation and found that we're using Wix 2, so I'm guessing that's why we couldn't use PermissionEx.

这篇关于Wix:CustomAction设置文件夹权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆