我通常完全按照 Ryu 所做的那样使用 WinSCP,但是我更进一步,使用 WinSCP 的脚本功能来映射更可定制的部署。
我在一篇详细介绍完整设置的博客文章中对此进行了详细说明:
http://www.diaryofaninja.com/blog/2010/09/21/continuous-integration-tip-1-ndash-ftp-deployment
然而,它的基本要点是将脚本文件传递给 WinSCP,如下所示:
<Target Name="AfterBuild">
<!-- Set the path to your FTP program (winscp) -->
<PropertyGroup>
<PathToWinSCP>"C:\Program Files (x86)\WinSCP\winscp.exe"</PathToWinSCP>
</PropertyGroup>
<!-- Get the date as a string for our log filename-->
<GetDate Format="yyyyMMdd">
<Output PropertyName="DateString" TaskParameter="Date"/>
</GetDate>
<!-- Convert the path to an absolute path -->
<ConvertToAbsolutePath Paths="$(OutputPath)">
<Output TaskParameter="AbsolutePaths" PropertyName="OutputPath"/>
</ConvertToAbsolutePath>
<!-- Fire WinSCP and give it your script files name
as well as passing it the parameter to this build -->
<Exec Command="$(PathToWinSCP) /script=$(OutputPath)Deployment\FtpDeployment.config /parameter $(OutputPath) /log=$(OutputPath)FtpLog-$(DateString).txt" />
</Target>
我的脚本看起来像:
option batch abort
option confirm off
open ftp://myUsername:myPassword@ftp.myftpsite.com
put %1%\*
rm FtpDeployment.config
exit