Q:

GoCD Nuget issue

I have a project and my agent does have nuget installed - Not sue what I am doign wwong
12:01:14.195 [go] Start to build DemoApp/20/second/1/secondJob on vivians-mbp-2.delta.rl.delta.com [/Users/vivianaranha/Library/Application Support/Go Agent]
12:01:14.195 [go] Current job status: passed.

12:01:14.195 [go] Start to execute task: <exec command="nuget restore packages.config -PackagesDirectory ..\..\packages" workingdir="EMApp\EMApp\EMApp.iOS" />.
12:01:14.199 Error happened while attempting to execute 'nuget restore packages.config -PackagesDirectory ..\..\packages'. 
Please make sure [nuget restore packages.config -PackagesDirectory ..\..\packages] can be executed on this agent.

12:01:14.199 [Debug Information] Environment variable PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/bin
12:01:14.206 [go] Current job status: failed.

A:

You are making a common mistake in GoCD expecting exec task to be a shell execution.
By that build log, I can tell that your configuration in xml is
<exec command="nuget restore packages.config -PackagesDirectory ..\..\packages" workingdir="EMApp\EMApp\EMApp.iOS">
</exec>

That means GoCD would be trying to execute a file whose path is nuget restore packages.config -PackagesDirectory ..\..\packages, which does not exist.
GoCD exec task requires you to explicitly separate process executable and all arguments. So the above nuget example would have to be configured like so:
<exec command="nuget" workingdir="EMApp\EMApp\EMApp.iOS">
   <arg>restore</arg>
   <arg>packages.config</arg>
   <arg>-PackagesDirectory</arg>
   <arg>..\..\packages</arg>
</exec>

More tips on task setup:

If nuget.exe is not in the PATH, you'll need to configure full file path  e.g. command="C:\nuget\nuget.exe"
Here is a nice blog post on exec tasks
If you don't like setting up process and arguments separately like this, try script executor plugin which will start a shell.

Edit 1
On mac you would need to run nuget with mono. So the process executable is  mono:
<exec command="mono" workingdir="EMApp\EMApp\EMApp.iOS">
   <arg>/path/to/nuget</arg>
   <arg>restore</arg>
   <arg>packages.config</arg>
   <arg>-PackagesDirectory</arg>
   <arg>..\..\packages</arg>
</exec>

