My blog has moved!
You should be automatically redirected in 5 seconds. If not, visit http://samueladesoga.wordpress.com and update your bookmarks.

Friday 29 August 2008

Nant SCP Task: deploy file to a remote server

Actually started the task by attempting to use MSBuild to deploy my application to a remote server.
which would require some secure means, scp, sftp or something of that sort.
The closest i got was SSHSharp which was written by a third party and not thoroughly tested,
i then decided maybe that wasn't the path to go.

Tried to go for Nant instead, and found that Nant core doesnt have a task for secure copy,
Hence, the other option was NantContrib which seem okay to an extent, except for incomplete documentation.

Once big issue was having a "scp" failed to start ---> The file cannot be found error when i tried to execute the build file. I spent a great deal of my time trying to figure out what file was not found, thinking it was my file that i intend to copy that wasn't found.

Actually it was the program "scp.exe" that could not be found, it took a lot of time and guesses, as there weren't a lot of resources on the
search engines about this. May be i was just being dumb. So i had to install pscp on my machine and add that to the path.

and it works fine...........

Summary is that you for you to use the scp task,

Download the nantcontrib dll files and read the "ReadMe.txt"


And add that to your Target with uses the SCP task

loadtasks assembly="${project::get-base-directory()}/lib_build/nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll"

This would the directory where your .dll files are.
Make sure that that scp which is default is installed on your machine, you could actually use other application , e.g pscp, ssh bu that would have to the specified in the SCP task.

Finally, This is what my file looked like:

<?xml version="1.0"?>
<project name="Project Name" default="DeployToPlay" basedir=".">
<property name="debug" value="true" overwrite="false" />

<target name ="DeployToServer">
<loadtasks assembly="${project::get-base-directory()}/lib_build/nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll" />

<zip zipfile="myapplication.zip" >
<fileset>
<include name = "*.aspx;*.asax;web.config"/>
<include name = "Content\**\*.*"/>
<include name = "home\**\*.*"/>
<include name = "Views\**\*.*"/>
<include name = "bin\Debug\**\*.*"/>
</fileset>
</zip>
<scp file="myapplication.zip" server="myservername" path="/pathOnTheServer" />
</target>

</project>
















No comments: