Forum Discussion
Issues with PowerShell start and end scripts
I think there is a problem with the PSFLauncher.exe. It appears to be using the working directory of the application shortcut to find the StartingScriptWrapper.ps1. This is breaking PowerShell support in PSFTooling and Advanced Installer Express. Is this expected behavior? I can think of lots of reasons not to have things working this way.
Hi Skinheed
I am Bogdan, from the Advanced Installer team. Thanks for reporting this issue. Just wanted to let you know that until a fix is included by MSFT in the official PSF repo we will include a custom fix directly inside our next version.
Until then, you have a workaround in Advanced Installer:
Advanced Installer allows you to update the working directory and application parameters (that you would usually specify in the "Application Details" view) directly from the PS1 script.
For your scenario, please follow these steps.- Go to "Application Details > Working directory" and make sure this field (Working Directory) is empty.
- Use a PS script that updates the Working directory, attached is a sample.
This sample PS script (from the attached zip) updates the Working directory to the first argument it receives (its value should be relative to APPDIR).
IMPORTANT, when using the above script:
- change the script to include your own ApplicationID.
- set the desired working directory path (relative to APPDIR) in the 'scriptArguments' field.
The Working Dir argument can also be changed directly from inside your PS1 script, if you wish to hardcode it inside the script. - set the 'waitForScriptToFinish' field to 'true'
Let me know if this helps.
11 Replies
- Bogdan MitracheIron Contributor
Hi Skinheed
I am Bogdan, from the Advanced Installer team. Thanks for reporting this issue. Just wanted to let you know that until a fix is included by MSFT in the official PSF repo we will include a custom fix directly inside our next version.
Until then, you have a workaround in Advanced Installer:
Advanced Installer allows you to update the working directory and application parameters (that you would usually specify in the "Application Details" view) directly from the PS1 script.
For your scenario, please follow these steps.- Go to "Application Details > Working directory" and make sure this field (Working Directory) is empty.
- Use a PS script that updates the Working directory, attached is a sample.
This sample PS script (from the attached zip) updates the Working directory to the first argument it receives (its value should be relative to APPDIR).
IMPORTANT, when using the above script:
- change the script to include your own ApplicationID.
- set the desired working directory path (relative to APPDIR) in the 'scriptArguments' field.
The Working Dir argument can also be changed directly from inside your PS1 script, if you wish to hardcode it inside the script. - set the 'waitForScriptToFinish' field to 'true'
Let me know if this helps.
- SkinheedCopper ContributorHi Bogdan,
I have had a chance to test this out and the PowerShell script is still not being executed. Running Procmon I see no PowerShell process at all, only the AIStub.exe which is finding my script file in the application root. I don't think the StartingScriptWrapper.ps1 is running either, I cant find any reference to it in Procmon. The application starts with no error it just doesn't run the script and I see no PowerShell window even though I have set it to show.- Bogdan MitracheIron Contributor
Hi Skinheed,
I've published an update for AI Express in the store today (it should pass MS validation in a few hours).
Download this update and try the old project. It should not require the workaround I suggested in my previous answer.
Cheers,
Bogdan
- Darren_Hoehna
Microsoft
Skinheed
Thank you for posting in our forums. Thank you for bringing up this issue with PSF. The expected behavior for Powershell scripts is the root of the application directory, not the directory of the shortcut. This is an issue with PSF and would need to be fixed.
Can you please make an issue on the MSIX_PackageSupportFramework github repo here: https://github.com/microsoft/MSIX-PackageSupportFramework/issues. This is where all the issues for PSF are being tracked.
Thanks,
Darren.- Darren,
I have gotten the same issue/request from another customer. PsfTooling is unable to place the file at the root folder since it doesn't exist yet. A modification to the launching code will be needed to allow for this case. It's actually a lot like the config.json file location issue I previously fixed. TMEditX does add these to the root folder of the package so it doesn't have this problem with scripts.