(#2345) Avoid any trailing spaces after silentArgs
Description Of Changes
Fix a bug where concatenating $silentArgs and $additionalInstallArgs adds a trailing space at the end of $silentArgs even when $additionalInstallArgs is empty. Such trailing space can change the meaning of the last positional argument (that may contain spaces).
Final arguments are now created as space joined string arrays filtered down to only non-empty items. Fix is applied to all installer types.
Motivation and Context
I have some installers doing similar thing as Total Commander (mentioned in #2345 ) - passing installation destination as last positional argument allowing spaces in it. Added trailing space caused by "$silentArgs $additionalInstallArgs" when $additionalInstallArgs is empty breaks this mechanism and attempts to install to path that ends with space.
NOTE: I am just an ordinary PowerShell user and not really skilled in it so any input on how to get this thing done is welcome. Also wasn't sure if its worth to apply this beyond EXE type as MSI has its own way of passing arguments. Motivation to fix all types is mostly uniformity.
Testing
- Tested installation of several .exe installers (made up mocks and Total Commander) on Windows 11
Change Types Made
- [x] Bug fix (non-breaking change).
- [ ] Feature / Enhancement (non-breaking change).
- [ ] Breaking change (fix or feature that could cause existing functionality to change).
- [ ] Documentation changes.
- [x] PowerShell code changes.
Change Checklist
- [ ] Requires a change to the documentation.
- [ ] Documentation has been updated.
- [ ] Tests to cover my changes, have been added.
- [ ] All new and existing tests passed?
- [ ] PowerShell code changes: PowerShell v2 compatibility checked?
Related Issue
Fixes: #2345