views:

373

answers:

5

Hi,


Does anyone know of an SFTP task for msbuild? We'd like to automate our deployments to production, but for security reasons we don't allow SMB file-share access from our dev/test/build environment to production.

Right now, developers deploy code by manually uploading the files using FileZilla, over an SFTP connection. This is pretty error-prone, so we're planning to automate the SFTP upload. Though if there's some mechanism other than SFTP which would be just as secure, I'd be happy to use that instead.

I'm thinking of just using the "exec" msbuild task, and a command-line ftp client such as pscp. But if someone's built an sftp task already, that would of course be great.


Thanks,
Richard

A: 

edtFTPnet/PRO offers full support for SFTP in .NET.

If you are interested in purchasing a copy we'd be happy to write an MSBuild SFTP task for you - it'd be a handy feature. Contact details on the site.

Bruce Blackshaw
+2  A: 

Could install WinSCP and just use the MsBuild Exec Task

I used something like the following to upload an ISO file to a server after a build.

winscp.exe sftp://root:password;@192.168.0.200:22/uploaddir/ "c:\myfile.iso"
Ryu
A: 

Install putty and use the commandline tools to sftp your files to the server. Use pagent and keys to avoid hardcoding or typing your password repeatedly.

Niels Castle
+1  A: 

FileZilla also supports this from the command line.

Bernard Vander Beken
A: 

I usually do EXACTLY as Ryu has done and use WinSCP, however i take it one step further and use WinSCP's scripting capabilities to map a more customizable deployment.

I've detailed this in a blog post that details the full setup:

http://www.diaryofaninja.com/blog/2010/09/21/continuous-integration-tip-1-ndash-ftp-deployment

however the basic gist of it is passing in a script file to WinSCP as follows:

<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> 

and my script looks like:

option batch abort
option confirm off

open ftp://myUsername:[email protected]

put %1%\*

rm FtpDeployment.config

exit 
Doug