tags:

views:

19

answers:

1

Hi,

I want to use rake to deploy a .net website to a windows server... Bit new at this and getting stuck with the very simple stuff...

How would I copy a directory from a local folder to a different windows server?

At the moment I have:

task :default => :CWS_Web_application

desc 'Depoly CWS Web application to preview environment'
task :CWS_Web_application do
    sh "echo Depoly CWS Web application to preview environment"
mv('MyDirectory', '//servername/c$/foldername', :verbose => true)
end

This obviously doesn't work - I believe the problem being the server path: '//servername/c$/foldername'

Can anyone point me in the right direction?

+1  A: 

This being ruby mixed with windows there's going to be multiple ways to do this, but here's what I've done by piping stuff to cmd.exe:

sh "del /q /f /s \\\\servername\\c$\\foldername\\subfoldername\\*.*"
sh "XCOPY .\\source_directory \\\\servername\\c$\\foldername\\subfoldername /E /Exclude:xcopy_excludes.txt"
sh "COPY .\\config\\website\\servername\\#{BUILD_CONFIGURATION}\\web.config \\\\servername\\c$\\foldername\\subfoldername"

You can also do stuff like:

sh "net use O: \\\\servername\\c$\\foldername\\subfoldername"
sh "copy *.* O:"
sh "net use O: /delete"

if that's preferred which potentially lets you put in username and passwords as well if required. The account running the rake script will obviously need appropriate permissions on the domain / directories etc. etc.

There's probably other ways of getting around escaping the \'s but I just went with the first thing that worked for me.

Gordon Hartley