質問

してい WiX インストーラとシングルのカスタムアクション(プラスアンドゥバトン)で使用財産からのインストーラを起動します。のカスタムアクションを起こすべてのファイルのハードディスク.そうする必要のある16の応募のWXSファイル、八内のルートはこのように:

<CustomAction Id="SetForRollbackDo" Execute="immediate" Property="RollbackDo" Value="[MYPROP]"/>
<CustomAction Id="RollbackDo" Execute="rollback" BinaryKey="MyDLL" DllEntry="UndoThing" Return="ignore"/>
<CustomAction Id="SetForDo" Execute="immediate" Property="Do" Value="[MYPROP]"/>
<CustomAction Id="Do" Execute="deferred" BinaryKey="MyDLL" DllEntry="DoThing" Return="check"/>
<CustomAction Id="SetForRollbackUndo" Execute="immediate" Property="RollbackUndo" Value="[MYPROP]"/>
<CustomAction Id="RollbackUndo" Execute="rollback" BinaryKey="MyDLL" DllEntry="DoThing" Return="ignore"/>
<CustomAction Id="SetForUndo" Execute="immediate" Property="Undo" Value="[MYPROP]"/>
<CustomAction Id="Undo" Execute="deferred" BinaryKey="MyDLL" DllEntry="UndoThing" Return="check"/>

八内 InstallExecuteSequence, のような:

<Custom Action="SetForRollbackDo" After="InstallFiles">REMOVE&lt;>"ALL"</Custom>
<Custom Action="RollbackDo" After="SetForRollbackDo">REMOVE&lt;>"ALL"</Custom>
<Custom Action="SetForDo" After="RollbackDo">REMOVE&lt;>"ALL"</Custom>
<Custom Action="Do" After="SetForDo">REMOVE&lt;>"ALL"</Custom>
<Custom Action="SetForRollbackUndo" After="InstallInitialize">REMOVE="ALL"</Custom>
<Custom Action="RollbackUndo" After="SetForRollbackUndo">REMOVE="ALL"</Custom>
<Custom Action="SetForUndo" After="RollbackUndo">REMOVE="ALL"</Custom>
<Custom Action="Undo" After="SetForUndo">REMOVE="ALL"</Custom>

ありそうです。

役に立ちましたか?

解決

また、同じ問題を書くときWiXインストーラー.私のアプローチの問題は何をどのようなマイクを提案しているブログ 実施WiXカスタムアクション第2部使用カスタムテーブル.

短に定義することができるカスタムテーブルにデータ:

<CustomTable Id="LocalGroupPermissionTable">
    <Column Id="GroupName" Category="Text" PrimaryKey="yes" Type="string"/>
    <Column Id="ACL" Category="Text" PrimaryKey="no" Type="string"/>
    <Row>
        <Data Column="GroupName">GroupToCreate</Data>
        <Data Column="ACL">SeIncreaseQuotaPrivilege</Data>
    </Row>
</CustomTable>

その後の書きシングルが即時にカスタムアクションはスケジュールの繰り延ロールバック、コミットカスタムアクション:

extern "C" UINT __stdcall ScheduleLocalGroupCreation(MSIHANDLE hInstall)
{
    try {
        ScheduleAction(hInstall,L"SELECT * FROM CreateLocalGroupTable", L"CA.LocalGroupCustomAction.deferred", L"create");
        ScheduleAction(hInstall,L"SELECT * FROM CreateLocalGroupTable", L"CA.LocalGroupCustomAction.rollback", L"create");
    }
    catch( CMsiException & ) {
        return ERROR_INSTALL_FAILURE;
    }
    return ERROR_SUCCESS;
}

以下のコードでは日程aシングルのカスタムです。基本的にはあなただけのカスタムテーブルを読みにいくのスキーマのカスタムテーブルを呼び出し MsiViewGetColumnInfo()その形式の性質が必要に CustomActionData 財いフォームをご利用 /propname:value, が利用できるものします。

void ScheduleAction(MSIHANDLE hInstall,
            const wchar_t *szQueryString,
            const wchar_t *szCustomActionName,
            const wchar_t *szAction)
{
    CTableView view(hInstall,szQueryString);
    PMSIHANDLE record;

    //For each record in the custom action table
    while( view.Fetch(record) ) {
        //get the "GroupName" property
        wchar_t recordBuf[2048] = {0};
        DWORD    dwBufSize(_countof(recordBuf));
        MsiRecordGetString(record, view.GetPropIdx(L"GroupName"), recordBuf, &dwBufSize);

        //Format two properties "GroupName" and "Operation" into
        //the custom action data string.
        CCustomActionDataUtil formatter;
        formatter.addProp(L"GroupName", recordBuf);
        formatter.addProp(L"Operation", szAction );

        //Set the "CustomActionData" property".
        MsiSetProperty(hInstall,szCustomActionName,formatter.GetCustomActionData());

        //Add the custom action into installation script. Each
        //MsiDoAction adds a distinct custom action into the
        //script, so if we have multiple entries in the custom
        //action table, the deferred custom action will be called
        //multiple times.
        nRet = MsiDoAction(hInstall,szCustomActionName);
    }
}

としての実施のための繰り延ロールバックやコミットカスタムアクションへの使用機能-利用 MsiGetMode() の区別は何をすべき:

extern "C" UINT __stdcall LocalGroupCustomAction(MSIHANDLE hInstall)
{
    try {
        //Parse the properties from the "CustomActionData" property
        std::map<std::wstring,std::wstring> mapProps;
        {
            wchar_t szBuf[2048]={0};
            DWORD dwBufSize = _countof(szBuf); MsiGetProperty(hInstall,L"CustomActionData",szBuf,&dwBufSize);
            CCustomActionDataUtil::ParseCustomActionData(szBuf,mapProps);
        }

        //Find the "GroupName" and "Operation" property
        std::wstring sGroupName;
        bool bCreate = false;
        std::map<std::wstring,std::wstring>::const_iterator it;
        it = mapProps.find(L"GroupName");
        if( mapProps.end() != it ) sGroupName = it->second;
        it = mapProps.find(L"Operation");
        if( mapProps.end() != it )
            bCreate = wcscmp(it->second.c_str(),L"create") == 0 ? true : false ;

        //Since we know what opeartion to perform, and we know whether it is
        //running rollback, commit or deferred script by MsiGetMode, the
        //implementation is straight forward
        if( MsiGetMode(hInstall,MSIRUNMODE_SCHEDULED) ) {
            if( bCreate )
                CreateLocalGroup(sGroupName.c_str());
            else
                DeleteLocalGroup(sGroupName.c_str());
        }
        else if( MsiGetMode(hInstall,MSIRUNMODE_ROLLBACK) ) {
            if( bCreate )
                DeleteLocalGroup(sGroupName.c_str());
            else
                CreateLocalGroup(sGroupName.c_str());
        }
    }
    catch( CMsiException & ) {
        return ERROR_INSTALL_FAILURE;
    }
    return ERROR_SUCCESS;
}

により、上記の手法は、代表的なカスタムアクションセット低減することができます。カスタムアクションテーブルにエントリー数:

<CustomAction Id="CA.ScheduleLocalGroupCreation"
              Return="check"
              Execute="immediate"
              BinaryKey="CustomActionDLL"
              DllEntry="ScheduleLocalGroupCreation"
              HideTarget="yes"/>
<CustomAction Id="CA.ScheduleLocalGroupDeletion"
              Return="check"
              Execute="immediate"
              BinaryKey="CustomActionDLL"
              DllEntry="ScheduleLocalGroupDeletion"
              HideTarget="yes"/>
<CustomAction Id="CA.LocalGroupCustomAction.deferred"
              Return="check"
              Execute="deferred"
              BinaryKey="CustomActionDLL"
              DllEntry="LocalGroupCustomAction"
              HideTarget="yes"/>
<CustomAction Id="CA.LocalGroupCustomAction.commit"
              Return="check"
              Execute="commit"
              BinaryKey="CustomActionDLL"
              DllEntry="LocalGroupCustomAction"
              HideTarget="yes"/>
<CustomAction Id="CA.LocalGroupCustomAction.rollback"
              Return="check"
              Execute="rollback"
              BinaryKey="CustomActionDLL"
              DllEntry="LocalGroupCustomAction"
              HideTarget="yes"/>

とInstallSquence表すエントリー数:

<InstallExecuteSequence>
    <Custom Action="CA.ScheduleLocalGroupCreation" 
            After="InstallFiles">
        Not Installed
    </Custom>
    <Custom Action="CA.ScheduleLocalGroupDeletion" 
            After="InstallFiles">
        Installed
    </Custom>
</InstallExecuteSequence>

また、少しの努力のコードを書き込めるかどうかを示しまし再利用するなどの読解からカスタムテーブルの特性をフォーマットの必要性、設定CustomActionData性のエントリにカスタムアクションテーブル現在はアプリ固有のアプリケーション固有のデータを書き、カスタムのテーブルまでカスタムアクションテーブルのファイルだけを含むことで各WiXます。

のためのカスタムアクションDLLファイルの用途でお使いいただくために、データからの読み込み、カスタムテーブルを変えることで、アプリ固有の詳細のDLLの実装のカスタムアクションテーブルな図書館は、このように容易に再利用しています。

こうして現在は書いていっWiXカスタムアクションの場合、誰でも知っていて今後のさらなる改善のために私は非常に感謝します。:)

(も見ることができる完全なソースコードを自分のブログ 実施Wixカスタムアクション第2部使用カスタムテーブル.).

他のヒント

のWiXカスタムアクションは素晴らしいモデルです。この場合にだけを宣言するのに、 CustomAction, 当面の行動、繰延ーションを生み出す行動を取るロールバックです。ごみの日程で、 Custom, 当面の行動が、当面の行動として実装コードをネイティブDLL.

その後、当面のアクションならではの コード, お電話 MsiDoAction スケジュールをロールバックおよび繰延。って繰り延べ、その記述のスクリプトを呼び出す MsiDoAction より実行されます。する必要がありま話 MsiSetProperty どの設定をカスタムアクションデータです。

ダウンロードWiXソースコードの IISExtension 作品です。WiX行動の一般的構文解析のカスタムテーブルデータの生成を用の繰延アクションならではの物件に基づきます。

ていれば複雑なカスタムアクションのトをサポートする必要があるロールバックすると考え書Wixいます。拡張子は、通常の提供オーサリング支援(新しいXMLのタグがマップされるMSIテーブル作品リサイクルマテリアルの自動のスケジューリングカスタム行動します。

あれは仕事だけではな書面にカスタムアクションがごCAsに、一定レベルの複雑さ、利便性の高いオーサリングとの拡張を提供できる使い勝手は大きく変わります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top