Backport PR #2994: expanduser on %%file targets

closes #2993