How to update appsettings.json from wix custom actions with the values passed as parameter during command line installation?

前端 未结 1 692
孤街浪徒
孤街浪徒 2020-12-21 07:07

I’m currently working on a project where I am using Wix for the installer. My application is developed using .net core and having appsettings

相关标签:
1条回答
  • 2020-12-21 07:45

    You can't use session["BUFFER.SIZE"] in a deferred custom action.

    To pass a property from the MSI into a deferred custom action you need to use another action to set the value and then read that value in your custom action using a slightly different mechanism.

    On the wixtoolset page for custom action you'll see it has a special mention in the Property description pointing to this microsoft article which talks about how getting context in a deferred custom action works.

    An important thing to note about the second action is that its property value must be an exact match to the deferred custom action's Id value.

    <CustomAction Id="SetGetParsValues" Property="GetParsValues" Value="BUFFER.SIZE=[BUFFER.SIZE]" />
    
    <InstallExecuteSequence>
        <Custom Action="SetGetParsValues" Before="GetParsValues"><![CDATA[NOT Installed]]></Custom>
    </InstallExecuteSequence>
    

    then in your custom action you can access the value by changing your session["BUFFER.SIZE"] to be session.CustomActionData["BUFFER.SIZE"]

    It might also be useful for you to know about [#FileId] which gets evaluated as the install location of a component's File using the File's Id value. Then you can pass in two values to your custom action by updating the Value in the SetGetParsValues custom action to be Value="BUFFER.SIZE=[BUFFER.SIZE];JsonFilePath=[#JsonFileId]". I'm not 100% sure doing [#JsonFileId] will work there so you can also just set a property value before that and use the property value in the Custom action's Value.

    0 讨论(0)
提交回复
热议问题