Wix: Set semicolon to CustomActionData

后端 未结 3 1646
猫巷女王i
猫巷女王i 2021-01-19 14:22

I have a problem with setting data that contains semicolons to CustomActionData property. By default CustomActionData class uses semicolon as DataSeparator and it breaks my

相关标签:
3条回答
  • 2021-01-19 14:57

    Back in 2006 I wrote a blog article and sample project:

    InstallScript, meet CustomActionData

    Basically I used the pattern: /KEY1=VALUE1 /KEY2=VALUE2

    The library worked by calling a lookup function passing it "/KEY1=". It then returned all data until the end of until the next " /".

    Regardless I don't really use this much any more since I've moved onto C# DTF which has a CustomActionData class handles the derialization/deserialization for me.

    0 讨论(0)
  • 2021-01-19 15:14

    to pass a semicolon in your CustomActionData you should add one more semicolon.

    Example:

    CustomActionData="key1=value1;key2=value2.1;;value2.2;;value2.3" - this will pass key1=value1 and key2=value2.1;value2.2;value2.3

    If you don't know where the semicolons are then I guess you can create method that escapes them by replacing each semicolon with two semicolon.

    If there are more symbols that you don't know how to escape you easily find out creating a simple app that creates a CustomActionData instance, adds a key-value pair and outputs the CustomActionData string representation using ToString().

    Example:

    CustomActionData data = new CustomActionData();
    data.Add("key1", "value1");
    data.Add("key2", "value2.1;value2.2;value2.3");
    
    Console.WriteLine(data.ToString());
    

    I hope the information is helpful.

    0 讨论(0)
  • 2021-01-19 15:14

    JSON Strings: Chris Painter - who has also answered this question with an older approach - has a blog entry that revolutionizes CustomActionData handling by using JSON strings. Now there is no string parsing to do, so far as you use a proper JSON library. Built-in serialization / deserialization: http://blog.iswix.com/2011/10/beam-me-up-using-json-to-serialize.html.

    Technically: The technical nitty-gritties would be different depending on language, but JSON strings themselves are simple:

    Groups=[{"Name":"Rockers","Description":"People who rock!"}]
    

    You can resurrect an object in deferred mode! Just by calling Serialize and Deserialize.

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