Closed wojwal closed 9 years ago
This seems very project-specific, or am I missing something? I've never needed to "escape" a path like this in the many installers I've written. Why would everybody need this?
You can achieve this by transforming a variable with a plain string replacement, no?
The file I'm modyfing via SystemTools:TemplateFile is actually in JSON format - thats why it need escaping.
It's used for Firebreath project for Chrome Native Messaging host file, sample here:
https://developer.chrome.com/extensions/nativeMessaging
"path" is the only property that I need to modify via MSI - other data is static. Actually I don't see other way how to solve it - and this attribute is optional... If someone will use it - thats cool - but if not - hey it's just an option ;)
In previous sample usage:
<SystemTools:TemplateFileProperty Id="FILENAME_property" Name="Filepath" Value="[INSTALLDIR]somefile.exe" Escape="yes" />
INSTALLDIR - is just WiX
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="SomeNameHere">
... components here ....
</Directory>
</Directory>
Hold your horses :) MSIExt is a generic library. If we implement everybody's quirks we're going to have a big mess. Tomorrow someone will want a lowercase path, or a URL-escaped path, will we also add LowerCase=true and EscapeToLookLikeAUrl=true? I don't think so. Convince me that this is a generic behavior of the CA and we can move forward - so far I think this is a weird requirement from Chrome Native Messaging.
Did you try in an immediate sequence to transform and set INSTALLDIR_ESCAPED with a string remplacement CA, then you use that in the TemplateFileProperty?
Well - JSON is very popular data/file format these days... I don't agree it's weired ;)
To be honest, I wouldn't mind to see LowerCase and other string transform attributes ;) This is what extensions are about, to make it's use easier, right? I would code it different if I have more requirements - like single "Transform" attribute where user could define different transforms. But I needed only escape.
Unfortunately I'm not that familiar with MSI and WiX - so I'm not sure what do you ment by "immediate sequence to transform" ? ;( If you could give me some links or samples - it would be cool ;)
And from what I found msiext was the only way in WiX to template text file (json in my case).
JSON says nothing about paths being "escaped".
See http://ehc.ac/p/wix/mailman/message/25312116 for an old thread that has a working example of String_Replace. Start there.
Thanks, I'll take a look at it later today...
As for JSON strings - minimum requirement is that quotes (") and backslash () are escaped... Pls see http://json.org/
Pls try JSON validator: http://jsonlint.com/ with the sample json from Native Messaging Host https://developer.chrome.com/extensions/nativeMessaging - if you remove double quotes and make it single quotes - it's no longer valid JSON
Clearly TemplateFile knows nothing about JSON, and I'd like it not to know anything about JSON. It cannot support just about every format. For MsiExt to take something it needs to be generic. Maybe you could write a custom action that takes text and escapes it making it valid JSON, or better, write an extension called JSONFile that updates JSON field values and knows in that case how to deal with the specifics of it.
I'll close this without merging in the meantime. Thanks for hanging out there and for submitting it!
Hi,
This is what I needed for my project... As mentioned before I needed the path to have double slashes...
Sample usage:
Not a big deal - and it's optional... Hope you will merge it ;)