Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut "Target" produces unexpected results for many supported WiX environment constants #1580

Closed
S1r0hub opened this issue Jul 8, 2024 · 4 comments

Comments

@S1r0hub
Copy link

S1r0hub commented Jul 8, 2024

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 :)

@oleg-shilo
Copy link
Owner

oleg-shilo commented Jul 9, 2024

Thank you for such a detailed report. I will investigate.

@oleg-shilo
Copy link
Owner

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.

@S1r0hub
Copy link
Author

S1r0hub commented Jul 12, 2024

Great to hear!
Thanks for the quick fix.

oleg-shilo added a commit that referenced this issue Jul 13, 2024
- #1580 Shortcut "Target" produces unexpected results for many supported WiX environment constants
- #1574: Cannot build .net 8 example project (NET-Core)
- #1546: dotnet tool install --global wix - Need for all users
- #1585:  Dotnet tool should not be relied on for wixsharp.   Added error logging on `dotnet` or `wix` not found.
- Added error log for failure to find WiX extension. Triggered by #1574, #1589
- Improved the documentation for `AutoElements` and `Compiler.AutoGeneration` (triggered by #1578)
- #7591: added WiX5 Custom BA sample (`<wixsharp>\Source\src\WixSharp.Samples\Wix# Samples\Bootstrapper\WiX5-Spike\WixToolset.WixBA`)
- added missing SilentBA for `WixSharp.Core`
- fixed problem with `SetShellSize` not setting the top level window size
@S1r0hub
Copy link
Author

S1r0hub commented Jul 17, 2024

Tested it. Thanks again for fixing.
Closing this issue now :)

@S1r0hub S1r0hub closed this as completed Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants