为什么WiX会忽略自定义功能?

时间:2017-02-22 11:48:36

标签: c wix custom-function

我创建了一个示例WiX项目来测试基于C的自定义操作。这是自定义动作函数DLL的C代码:

unsigned WINAPI SetDeviceType (MSIHANDLE installer) {
    MsiSetProperty(installer, TEXT("DEVICETYPE"), TEXT("3"));
    return(ERROR_SUCCESS);
}

以下是我的WiX项目的重要部分:

<Binary Id="Message" SourceFile="Message.dll" />
<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
        <Directory Id="CompanyFolder" Name="MyCompany">
            <Directory Id="APPLICATIONROOTDIRECTORY" Name="Test">
                <Component Id="TestFolder" Guid="c54ec545-4074-424f-a54e-b57f375ed3fc">
                    <File Id="Setup_wixproj" Source="setup.wixproj" Vital="yes" />
                </Component>
                <Component Id="TestFolder1" Guid="c54ec5f5-4074-424f-a54e-b57f375ed3fc">
                    <File Id="Setup1_wixproj" Source="setup1.wixproj" Vital="yes" />
                </Component>
            </Directory>
        </Directory>
    </Directory>
</Directory>
<Feature Id="AllFeature" Title="All" Level="1">
    <Feature Id="TempFeature" Title="Temp" Level="1">
        <ComponentRef Id="TestFolder" />
        <Condition Level="0">
            <![CDATA[DEVICETYPE <> 3]]>
        </Condition>
    </Feature>
    <Feature Id="AlwaysFeature" Title="Always" Level="1">
        <ComponentRef Id="TestFolder1" />
    </Feature>
</Feature>
<InstallExecuteSequence>
    <Custom Action="Launch" After="AppSearch" />
</InstallExecuteSequence>
<CustomAction Id="Launch" BinaryKey="Message" DllEntry="SetDeviceType" Return="check" Execute="immediate" HideTarget="no" />

下面给出了有意义的MSI日志摘录 [...]

Action start 10:21:42: Launch.
MSI (s) (E4:48) [10:21:42:319]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIE532.tmp, Entrypoint: SetDeviceType
MSI (s) (E4:E4) [10:21:42:320]: Generating random cookie.
MSI (s) (E4:E4) [10:21:42:321]: Created Custom Action Server with PID 3000 (0xBB8).
MSI (s) (E4:54) [10:21:42:344]: Running as a service.
MSI (s) (E4:54) [10:21:42:345]: Hello, I'm your 32bit Impersonated custom action server.
MSI (s) (E4!44) [10:21:42:357]: PROPERTY CHANGE: Adding DEVICETYPE property. Its value is '3'.
Action ended 10:21:42: Launch. Return value 1.

[...]

Action start 10:21:42: InstallValidate.
MSI (s) (E4:8C) [10:21:42:361]: PROPERTY CHANGE: Deleting MsiRestartManagerSessionKey property. Its current value is 'ec922ccc9406da4baac466ba2db559b9'.
MSI (s) (E4:8C) [10:21:42:361]: Note: 1: 2205 2:  3: Dialog 
MSI (s) (E4:8C) [10:21:42:361]: Feature: TempFeature; Installed: Absent;   Request: Null;   Action: Null
MSI (s) (E4:8C) [10:21:42:361]: Feature: AllFeature; Installed: Absent;   Request: Local;   Action: Local
MSI (s) (E4:8C) [10:21:42:361]: Feature: AlwaysFeature; Installed: Absent;   Request: Local;   Action: Local
MSI (s) (E4:8C) [10:21:42:361]: Component: TestFolder; Installed: Absent;   Request: Null;   Action: Null
MSI (s) (E4:8C) [10:21:42:361]: Component: TestFolder1; Installed: Absent;   Request: Local;   Action: Local
MSI (s) (E4:8C) [10:21:42:361]: Note: 1: 2205 2:  3: Registry 
MSI (s) (E4:8C) [10:21:42:361]: Note: 1: 2205 2:  3: BindImage 
MSI (s) (E4:8C) [10:21:42:362]: Note: 1: 2205 2:  3: ProgId 
MSI (s) (E4:8C) [10:21:42:362]: Note: 1: 2205 2:  3: PublishComponent 
MSI (s) (E4:8C) [10:21:42:362]: Note: 1: 2205 2:  3: SelfReg 
MSI (s) (E4:8C) [10:21:42:362]: Note: 1: 2205 2:  3: Extension 
MSI (s) (E4:8C) [10:21:42:362]: Note: 1: 2205 2:  3: Font 
MSI (s) (E4:8C) [10:21:42:362]: Note: 1: 2205 2:  3: Shortcut 
MSI (s) (E4:8C) [10:21:42:362]: Note: 1: 2205 2:  3: Class 
MSI (s) (E4:8C) [10:21:42:362]: Note: 1: 2205 2:  3: Icon 
MSI (s) (E4:8C) [10:21:42:362]: Note: 1: 2205 2:  3: TypeLib 
MSI (s) (E4:8C) [10:21:42:365]: Note: 1: 2205 2:  3: _RemoveFilePath 
MSI (s) (E4:8C) [10:21:42:366]: PROPERTY CHANGE: Modifying CostingComplete property. Its current value is '0'. Its new value: '1'.
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: Registry 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: BindImage 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: ProgId 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: PublishComponent 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: SelfReg 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: Extension 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: Font 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: Shortcut 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: Class 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: Icon 
MSI (s) (E4:8C) [10:21:42:366]: Note: 1: 2205 2:  3: TypeLib 
MSI (s) (E4:8C) [10:21:42:367]: Note: 1: 2727 2:  
MSI (s) (E4:8C) [10:21:42:367]: Note: 1: 2205 2:  3: FilesInUse 
MSI (s) (E4:8C) [10:21:42:371]: Note: 1: 2727 2:  
Action ended 10:21:42: InstallValidate. Return value 1.

[...]

Action start 10:20:59: ExecuteAction.

[...]

根据MSI日志调用自定义操作函数并设置属性。但是feature中的条件从未得到满足,并且未安装该文件。如果我删除了这个条件,则会安装这两个文件 为什么它会像这样?

0 个答案:

没有答案