财产价值被破坏

发布于 2024-11-01 18:20:07 字数 226 浏览 0 评论 0原文

我像这样传递属性值:

property1=value1;property2=value2

但有时值包含“;”符号,这会导致 WiX 错误地反序列化属性字符串。我尝试过用双引号引用值

property1="value1";property2="value2"

,但这没有帮助。那么我该如何处理这个问题呢?

I pass property values like this:

property1=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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇纵 2024-11-08 18:20:07

我想我们前几天刚刚看到这个问题(简短的答案是用 ;; 转义它)

对于更详细的讨论,如果您想了解如何使用 Type 51 自定义操作来设置要由 DTF 自定义操作反序列化的属性,编写一个像这样的小控制台应用程序

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

结果将是:

property1=myvalue;property2=my;;值

这应该可以帮助您了解如何格式化每个可能的场景。然而,最终您可能会发现自己处于 51 型 CA 不够的情况。在这种情况下,您需要编写一个立即 CA 来构建您的 CustomActionData 集合,然后使用 Session.DoAction 方法来安排您的延迟 CA 将 CustomActionData 传递给它。

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.

小巷里的女流氓 2024-11-08 18:20:07

在评论中回复请求。要在属性值中使用双分号,您可以使用 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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文