开发者

property values get corrupt

I pass property values like this:

p开发者_如何转开发roperty1=value1;property2=value2

but sometimes values contain ';' symbols, which causes WiX to deserialize the property string incorrectly. I've tried enquoting values with double quotes

property1="value1";property2="value2"

but that didn't help. So how can I deal with this?


I thought we just saw this question the other day ( short answer is escape it with ;; )

For a more detailed discussion, if you want to understand how to use Type 51 custom actions to set properties to be deserialized by a DTF custom action, write a little console app like this

var cad = new CustomActionData();
cad.Add("property1","myvalue");
cad.Add("property2","my;value");
Console.WriteLine(cad.ToString());
Console.Read();

The result will be:

property1=myvalue;property2=my;;value

This should help you know how to format every scenario possible. However, eventually you might findyourself in a situation where a Type 51 CA isn't enough. In that case you'd write an immeadiate CA to build up your CustomActionData collection and then use the Session.DoAction method to schedule your deferred CA passing the CustomActionData through to it.


Replying to request in comments. To double semi-colons in a property value, you can use JScript CA:

<CustomAction Id="DoubleSemiColons" Script="jscript">
    <![CDATA[

    var s = Session.Property("property2");
    var re = /;/g;
    var r = s.replace(re, ";;");

    Session.Property("property2") = r;

    ]]>
</CustomAction>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜