Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upload file with FTP using nant

I have an NAnt script that I use to build my .NET project, and I'm looking to see if there is a way to upload the resulted assemblies to some remote folder using an FTP task.

I couldn't find any good example online, and I'm wondering if anyone knows how to do it, if it's doable at all.

FYI: I'm running it on a windows machine, if it makes any difference.

like image 252
Or A Avatar asked May 07 '10 20:05

Or A


3 Answers

You could use WinSCP as console application in a NAnt <exec> task. Using WinSCP will give You access to extra goodies like synchronization.

That's what we are doing and it works like a charm.

like image 122
The Chairman Avatar answered Oct 14 '22 23:10

The Chairman


Working WinSCP example here:

    <exec
        verbose="true"
        program="WinSCP.exe" 
        basedir="${WinSCP.Folder.Install}">
        <arg value="/command" />
        <arg value="/log=D:\Logs\WinSCP\winscp.log" />
        <arg value="/script=backup.winscp" />
        <arg line="/parameter ${YOUR_FILE}" />
    </exec>

where backup.winscp in above exec is a file with the following content

option batch abort
option confirm off 
open ftp://user:[email protected]
put "%1%"
exit
like image 45
fiat Avatar answered Oct 14 '22 22:10

fiat


Having the same need myself, I developed a basic FTP upload NAnt task. You can find it here: https://sourceforge.net/projects/w3c-nant/

Example usage (copy pasted from the site's API docs):

<ftpUpload host="ftp.myserver.com" username="root" password="r00t" todir="/">
    <fileset basedir="dist">
        <include name="**/*" />
        <exclude name="**/*.config" />
    </fileset>
</ftpUpload>

I already use it in my local build scripts to upload my site to its live server.

like image 36
Nikolaos Georgiou Avatar answered Oct 14 '22 23:10

Nikolaos Georgiou