Задайте вопросЗадайте вопрос
 

ВопросRunning module function in different run-space

  • 2 июля 2009 г. 0:46P. van der Velde Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Hi All

    I am trying to create a buildscript in powershell. I'm using Psake (http://code.google.com/p/psake/, the V2 branch) as my build engine. Psake is a Rake MsBuild like build tool and it has all kinds of useful functions / methods for creating build scripts. The problem I have is that I have one build script calling another build script. Unfortunately it seems that upon calling the run-psake function all the variables in use for the first call are re-used. For instance there are several collections which keep track of which actions to perform. As soon as the second build script finishes these collections get cleaned out and then the first build script fails because the collections have been removed.

    So in order to fix this problem I'm thinking of pushing each invokation of the run-psake script into a different runspace. I've tried to invoke powershell.exe and send a run-psake command into that powershell. Unfortunately it doesn't really seem to work. I get all kinds of errors and in the end my master process still errors out.

    Now the questions are:
    - How do I achieve this form a powershell script. aka how do I create a new runspace in powershell. If that is not possible I'll take C# code too :)
    - How can I make the second (or third or ...) runspace put it's output into the console that was used for the first runspace. I would like updates on the status of the process because the build process takes quite a long time and it would be good to get updates on progress.

    Thanks

    Patrick

Все ответы