The short story: use <NUL
More details:
I have been using Powershell as part of a build script for a
FlashDevelop project.
FlashDevelop project.
The problem was that the Powershell process did not terminate
and so fdbuild.exe did not continue to run.
and so fdbuild.exe did not continue to run.
I searched the web quite a lot until I found the following
two:
two:
- http://www.vistax64.com/powershell/156786-powershell-starts-but-never-exits-when-invoked-wscript-shell.html#post726229
- http://powershell.com/cs/blogs/tips/archive/2009/06/02/returning-text-information-from-powershell-to-vbscript.aspx
They deals with a similar problem that happens when executing
Powershell from WScript.
Powershell from WScript.
The explanation given that was that Powershell is waiting for
its STDIN stream to close before it exists and a workaround is
suggested there that fits WScript.
its STDIN stream to close before it exists and a workaround is
suggested there that fits WScript.
This got me to the following solution for running Powershell
from Flashdevelop/fdbuild/batch:
from Flashdevelop/fdbuild/batch:
since IMHO Powershell in those cases does not need any input
from STDIN I assigned NUL as its input stream.
from STDIN I assigned NUL as its input stream.
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
-Noninteractive -Command "& {$postbuild = (get-item ((get-item
%1).parent.parent.Fullname + '/postbuild.ps1')); & $postbuild
-outputDir %1 -outputName %2; exit $lastexitcode}" <NUL
-Noninteractive -Command "& {$postbuild = (get-item ((get-item
%1).parent.parent.Fullname + '/postbuild.ps1')); & $postbuild
-outputDir %1 -outputName %2; exit $lastexitcode}" <NUL
I use this in a batch file that is called from the post-build
event using the following command line
event using the following command line
$(ProjectDir)\..\postbuild.bat $(OutputDir)
$(OutputName)
$(OutputName)
I guess I could call Powershell directly from the post-build
command line but this will have to wait.
command line but this will have to wait.
As far as I know I am the first to suggest this workaround,
please add a link to this post if youare quoting it. Thanks.
please add a link to this post if youare quoting it. Thanks.