Silently executing a PowerShell script from WiX Hangs PowerShell Silently executing a PowerShell script from WiX Hangs PowerShell powershell powershell

Silently executing a PowerShell script from WiX Hangs PowerShell


I saw several posts like this one while searching on an unrelated issue and found an answer. Bottom line: include the flag -InputFormat None in your command line.


Have you tried adding the keyword exit to the end of the script?

I came across a similar situation with a C# project I've been working on. After building the project, I invoke PowerShell in the <AfterBuild> target using MSBuild's <Exec> task, specifying the script to run. If the script did not include the exit keyword, VS2010 "hangs" - which is to say it's actually waiting for PowerShell to complete its task, while PowerShell waits for user input.

If you open up Task Manager or SysInternals Process Explorer, you will see powershell.exe running as if nothing's wrong. If you kill the process, VS2010 (i.e. MSBuild) throws an error.

So you will need to tell PowerShell that you are done with it by adding exit to the script it runs, and all should be well again.