Comments (7)
Start-Process -Wait -PassThru
is your friend for not standard cases like innosetup.
In your case something like
$process = Start-Process $installerPath "/verysilent /allusers /dir=$innoSetupDir" -Wait -PassThru
# check $process exit code here
I do not think any support from Invoke-Build
is needed for such cases.
(1) PowerShell out of the box tools do the job well.
(2) Commands like innosetup are not typical.
from invoke-build.
@CoenraadS I am not yet sure it's about exec
or Invoke-Build
. Can you run your command in plain PowerShell console?
& $installerPath /verysilent /allusers /dir=$innoSetupDir
The first command is not correct, indeed. The second looks correct. What is in your $installerPath
exactly? What errors do you get? What version of PowerShell and Invoke-Build do you use?
from invoke-build.
The full command is:
C:\Users\asdf\innosetup-6.2.2.exe /verysilent /allusers /dir=C:\Users\asdf\Example
If I run it directly in powershell, it also returns immediately, unless I add | Wait-Process
to the end.
=> Works ok:
C:\Users\asdf\innosetup-6.2.2.exe /verysilent /allusers /dir=C:\Users\asdf\Example | Wait-Process
But if I try to that to the exec block, I get Dangling scriptblock at...
errors.
e.g. exec { & $installerPath /verysilent /allusers /dir=$innoSetupDir | Wait-Process }
The innosetup installer does trigger a UAC prompt, not sure if related.
from invoke-build.
I do not think you use Wait-Process
how it is supposed to be used, see Wait-Process
from invoke-build.
Hmm I got it from this answer and it works for me: https://stackoverflow.com/a/24439202/4503491
Apparently in newer versions of Powershell it may not work anymore.
Powershell version: 5.1.19041.2364
Invoke Build version: 5.10.2
It's not really a big problem, for now I am just using my own helper function as workaround:
function Run{
param(
[String]$FilePath,
[String]$Arguments,
[Bool]$ContinueOnError = $False,
[Bool]$Echo = $True
)
if ($Echo)
{
"$FilePath $Arguments"
}
$elapsed = Measure-Command { $process = Start-Process -FilePath $FilePath -ArgumentList $Arguments -Wait -PassThru -NoNewWindow }
"Finished in $(Round $elapsed.TotalSeconds 2) seconds"
if ($ContinueOnError)
{
"Exited with status code $($process.ExitCode)"
return
}
if ($process.ExitCode -ne 0)
{
throw "Exited with status code $($process.ExitCode)"
}
}
from invoke-build.
Like I said, it is not about exec
or Invoke-Build
. It is about how innosetup works and you handle it in PowerShell. If it starts and returns immediately then you should not use exec
at all. Start it by Start-Process
and use -PassThru
in order to get the process instance. Then use this instance as input for Wait-Process
in order to wait for its exit and then get and check its exit code.
Disclaimer. I do not use innosetup, the above thoughts are just common sense.
from invoke-build.
Yes, but I use this nice framework so I could avoid having to write my own helper scripts. Would be nice to support this out of the box, since I don't think it's so unusual, that was all. Indeed I see now it has nothing to do with the forward arguments as I first though.
from invoke-build.
Related Issues (20)
- vscode outline view: no symbols found in document HOT 2
- Different module and package versions HOT 2
- Parallel execution based on dependency tree HOT 2
- invoke-build discovery fails in powershell container HOT 3
- Please consider adding -Computername and -Session parameter to Task HOT 8
- GitHub action output is not colored
- Color and formatting text in Azure DevOps Pipelines HOT 8
- Use-BuildEnv should make parameters mandatory
- Invoke-BuildExec spitting out service principal secret as current directory HOT 6
- Use `[System.Management.Automation.Cmdlet]::CommonParameters` to get the names of all common parameters HOT 3
- Task condition does not work HOT 8
- Build-Parallel writes only to Output stream HOT 7
- property 'File' cannot be found on this object HOT 17
- Do not wrap internal errors in Resolve-MSBuild
- Fix cryptic errors on unknown parameters
- Invoke-BuildExec should pass the original stderr error to the thrown terminating error HOT 38
- dotnet tool ib run script by default as powershell. Possible to configure? HOT 9
- echo output of exec {} block prints out entire parent object of a parameter when property of an object passed as parameter HOT 3
- Dot-sourcing common build script for multiple subprojects and parameters HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from invoke-build.