views:

233

answers:

2

hi,

i have a 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 of nant.

i couldn't find any good example online, and i'm wonder if anyone know how to do it, if its doable at all.

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

Thanks,

Ori

+1  A: 

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.

The Chairman
A: 

We using something like this (NAnt-0.86-beta1):

<!-- Copies files from artifacts folder to destination folder -->
<target name="deploy-configuration">
  <!-- Generate temporary folder for the processed web.config -->
  <property name="generated-config-file-path" value="${path::get-temp-path()}${common::GenerateGUID()}" />
  <mkdir dir="${generated-config-file-path}" />
  <!-- Copy -->
  <copy file="${artifacts.dir}/web.config" tofile="${generated-config-file-path}/web.config" />
  <!-- Update web.config with values for our destination environment before we deploy. -->
  <update-configuration-path file="${generated-config-file-path}\web.config" />
  <!-- Deploy using FTP -->
  <connection id="ftp-transfer-connection"
    server="${project.deployment.ftp.server}"
    username="${project.deployment.ftp.user}"
    password="${project.deployment.ftp.password}"
    />

  <ftp connection="ftp-transfer-connection"
       showdironconnect="false"
       createdirs="true"
       verbose="true"
       exec="true"
       logfiles="false"
       >

    <put type="bin"
         localdir="${generated-config-file-path}"
         remotedir="${project.deployment.path.remote}"
         flatten="false"
         >
      <include name="**\web.config" />
    </put>
  </ftp>
  <delete dir="${generated-config-file-path}" />
</target>


<target name="deploy">

  <connection id="ftp-transfer-connection"
    server="${project.deployment.ftp.server}"
    username="${project.deployment.ftp.user}"
    password="${project.deployment.ftp.password}"
    />

  <ftp connection="ftp-transfer-connection"
       showdironconnect="false"
       createdirs="true"
       verbose="true"
       exec="true"
       logfiles="false"
       >

    <put type="bin"
         localdir="${artifacts.dir}"
         remotedir="${project.deployment.path.remote}"
         flatten="false"
         >
      <include name="**\bin\**" />
      <include name=".\*.svc" />
      <include name=".\web.config" />
    </put>
  </ftp>
  <!-- Deploy configuration -->
  <call target="deploy-configuration" />
</target>
Martin