msbuild 的 SFTP 任务?

发布于 2024-07-21 05:54:14 字数 365 浏览 4 评论 0 原文




有谁知道 msbuild 的 SFTP 任务吗? 我们希望自动部署到生产环境,但出于安全原因,我们不允许从我们的开发/测试/构建环境到生产环境进行 SMB 文件共享访问。

目前,开发人员通过 SFTP 连接使用 FileZilla 手动上传文件来部署代码。 这很容易出错,因此我们计划自动执行 SFTP 上传。 不过,如果除了 SFTP 之外还有其他同样安全的机制,我很乐意使用它。

我正在考虑仅使用“exec”msbuild 任务和命令行 ftp 客户端(例如 pscp)。 但如果有人已经构建了 sftp 任务,那当然很棒。


谢谢,
理查德

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

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

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

发布评论

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

评论(6

冰魂雪魄 2024-07-28 05:54:14

可以安装 WinSCP 并仅使用 MsBuild Exec Task

我使用了类似的东西构建后将 ISO 文件上传到服务器。

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

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"
她说她爱他 2024-07-28 05:54:14

我通常完全按照 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:[email protected]

put %1%\*

rm FtpDeployment.config

exit 

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 
棒棒糖 2024-07-28 05:54:14

FileZilla 也支持 命令行

FileZilla also supports this from the command line.

时光礼记 2024-07-28 05:54:14

安装 putty 并使用命令行工具将文件通过 sftp 传输到服务器。 使用页面和按键来避免硬编码或重复输入密码。

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.

蘸点软妹酱 2024-07-28 05:54:14

有很多基于 .net 的 SSH 工具,选择一个并使用 msbuild 任务(创建您自己的)或 ccnet 任务包装它。

Ant 有一个 scp 任务,如果可能的话,从 msbuild 调用 ANT 脚本。 无论如何,使用强大的公钥/私钥进行加密。

There are lots of .net based SSH tool, take one and wrap it using msbuild task(create your own) or ccnet task.

Ant has a scp task, if possible call a ANT script from msbuild. whatever case use strong public/private key for encryption.

Hello爱情风 2024-07-28 05:54:14

edtFTPnet/PRO 为 .NET 中的 SFTP 提供全面支持。

如果您有兴趣购买副本,我们很乐意为您编写 MSBuild SFTP 任务 - 这将是一个方便的功能。 网站上的联系方式。

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.

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