This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
17 Replies Last post: Oct 29, 2008 4:23 PM by godefroi  
Peter Fransen Newbie 8 posts since
Jun 14, 2008
Currently Being Moderated

Jun 14, 2008 12:53 AM

Trouble with Powershell and NAnt during build

I'm trying out Teamcity as a possible replacement for our current CruiseControl installation.  Everything was going great until I got the agent up and running:

 

My NAnt build has an EXEC task for a powershell build.  Agent will hang indefinitely( > 30 minutes) on this task without moving.  Same task works fine if I execute NAnt from the commandline(even from the Work directory on the Agent).

 

Any ideas?

Eugene Petrenko JetBrains 2,209 posts since
Oct 4, 2004
Currently Being Moderated
Jun 18, 2008 1:47 PM in response to: Peter Fransen
Re: Trouble with Powershell and NAnt during build

What version of TeamCity do you use?

What version of NAnt is used?

 

Could you please send me hanging part of the script to reproduce.

 

Could you please try to capture logs from .NET part of TeamCity. For doing it please do the following:

- select some build agent

- open /tmp/buildTmp/TeamCity.NET folder.

Please attach all the files from that folder.

 

Thanks!

Eugene Petrenko JetBrains 2,209 posts since
Oct 4, 2004
Currently Being Moderated
Jun 18, 2008 6:34 PM in response to: Peter Fransen
Re: Trouble with Powershell and NAnt during build

Thanks. Seems array is broken.

You may email it to eugene[dot]petrenko]at[jetbrains.com

 

What is done under that powershell call? Does it produces much output?

Eugene Petrenko JetBrains 2,209 posts since
Oct 4, 2004
Currently Being Moderated
Jun 18, 2008 6:42 PM in response to: Peter Fransen
Re: Trouble with Powershell and NAnt during build

I got the logs.

 

Could you please try taking thread dumps feature for that hanging build. What is shown for NAnt process?

Thanks!

Eugene Petrenko JetBrains 2,209 posts since
Oct 4, 2004
Currently Being Moderated
Jun 19, 2008 9:52 AM in response to: Peter Fransen
Re: Trouble with Powershell and NAnt during build

So according to logs, I see that NAnt process is waiting for powershell to finish, while powershell is trying to read some file.

 

What user is used for build agent service? Does that user have enough rights to work? Sometimes SYSTEM accound does not match.

 

Could you please try settings some working folder for the script.

 

Let's replace powershell script with 'hello world' like script. Does that still hang?

 

Thanks!

Eugene Petrenko JetBrains 2,209 posts since
Oct 4, 2004
Currently Being Moderated
Jun 19, 2008 6:31 PM in response to: Peter Fransen
Re: Trouble with Powershell and NAnt during build

Thanks!

 

Could you please try running it under some real user on the machine. There were several issue on SYSTEM account used for build agent.

Oleg Gerovich Novice 104 posts since
Jun 4, 2008
Currently Being Moderated
Jun 19, 2008 11:31 PM in response to: Peter Fransen
Re: Trouble with Powershell and NAnt during build

Maybe the builder in TeamCity cannot find "..\script\test.ps1" because it starts in a different directory from the one you start in by hand?

Oleg Gerovich Novice 104 posts since
Jun 4, 2008
Currently Being Moderated
Jun 18, 2008 6:50 PM in response to: Peter Fransen
Re: Trouble with Powershell and NAnt during build

Peter,

 

I had something similar happen to me in Ant when I was trying to use task without the full path to the executable for perl. I ended up having to write something like this:

 


<property name="perl.dir" value="C:\Perl\bin">
...
<target name="mytarget">
    <exec executable="${perl.dir}\perl.exe">
        <arg value="myscript.pl"></arg>
    </exec>
</target>

 

I don't know if it would work in NAnt though.

 

Hope this helps,

Oleg.

godefroi Newbie 4 posts since
Oct 28, 2008
Currently Being Moderated
Oct 28, 2008 11:09 PM in response to: Peter Fransen
Re: Trouble with Powershell and NAnt during build

Peter,

 

Did you ever find a solution to the problem of powershell hanging waiting for input? I've managed to run into the same issue, and my thread trace looks identical. PowerShell.exe seems to be waiting for input.

 

I've actually managed to work around the issue by writing a batch file and causing TC to execute that instead of powershell.exe directly, and in the batch file I have something like this:

 

@echo off

echo whatsthedeal | powershell.exe -noninteractive -noprofile -nologo -command "& 'my_script.ps1'"

 

But that's not ideal for obvious reasons.

Yegor Yarko JetBrains 1,425 posts since
May 5, 2004
Currently Being Moderated
Oct 29, 2008 3:51 PM in response to: Peter Fransen
Re: Trouble with Powershell and NAnt during build

We created the issue to address the problem.  Eugene will look into it to investigate if this powershell limitation can be workarounded.

godefroi Newbie 4 posts since
Oct 28, 2008
Currently Being Moderated
Oct 29, 2008 4:23 PM in response to: Yegor Yarko
Re: Trouble with Powershell and NAnt during build

Note than I'm executing powershell.exe directly using the command line runner, and I've also tried executing a batch file instead that launched powershell.exe instead. Neither worked. The only way I got it to work was to put in my batch file something like:

 

echo something_nonsensical_here | powershell.exe {command line parameters here}

 

... in which case it worked. I ended up working around the issue by writing a small replacement tool for powershell.exe that would execute my powershell script.

More Like This

  • Retrieving data ...