Windows 上的 Rake - 将目录复制到另一台服务器

发布于 2024-09-08 16:22:46 字数 493 浏览 0 评论 0原文

我想使用 rake 将 .net 网站部署到 Windows 服务器...有点新,并且陷入了非常简单的东西...

我如何将目录从本地文件夹复制到不同的 Windows 服务器?

目前我有:

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

这显然不起作用 - 我相信问题出在服务器路径:'//servername/c$/foldername'

任何人都可以指出我正确的方向吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

埋葬我深情 2024-09-15 16:22:46

这是 ruby​​ 与 Windows 的混合,有多种方法可以做到这一点,但这是我通过将内容传输到 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"

您还可以执行以下操作:

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

如果这是首选,则可能允许您输入用户名和密码如果需要的话也可以。运行 rake 脚本的帐户显然需要对域/目录等进行适当的权限。

可能还有其他方法可以绕过 \ 的转义,但我只是选择了对我有用的第一件事。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文