Shortcut "Target" produces unexpected results for many supported WiX environment constants
S1r0hub opened this issue · 4 comments
When creating a shortcut (e.g. ExeFileShortcut), adding constants to the target path like this: "[WindowsFolder]AnyApp.exe" does not work properly.
I found that the normalization function "NormalizeWixString" (from Extensions.cs) only works as expected for the constants explicitly mentioned in it (e.g. SystemFolder), as those are replaced in prior to the following line and restored afterwards:
.Replace($"[{key.Trim('%')}]", Compiler.EnvironmentConstantsMapping[key])
The line that seems to cause these issues was added with commit fa97638 in June 2019.
It replaces known constants like "[WindowsFolder]" with the string from the mapping, which is just "WindowsFolder", and therefore, square brackets are removed.
As a result, for a target path like [WindowsFolder]AnyApp.exe
, the generated .wxs file will contain the invalid shortcut path WindowsFolderAnyApp.exe
.
Based on comments like "Protect ..." and "restore ..." in the normalization function, I wonder if this is really the desired behavior.
Thanks :)
Thank you for such a detailed report. I will investigate.
You were right. The original fix was incomplete.
Thank you for doing the research. Appreciate it.
Fixed now. It will be available in the very next release.
Great to hear!
Thanks for the quick fix.
Tested it. Thanks again for fixing.
Closing this issue now :)