GithubHelp home page GithubHelp logo

Comments (7)

nightroman avatar nightroman commented on June 26, 2024 1

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.

nightroman avatar nightroman commented on June 26, 2024

@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.

CoenraadS avatar CoenraadS commented on June 26, 2024

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.

nightroman avatar nightroman commented on June 26, 2024

I do not think you use Wait-Process how it is supposed to be used, see Wait-Process

from invoke-build.

CoenraadS avatar CoenraadS commented on June 26, 2024

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.

nightroman avatar nightroman commented on June 26, 2024

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.

CoenraadS avatar CoenraadS commented on June 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.