VSTS Windows 文件复制变量不起作用?

VSTS Windows File Copy Variables not working?

我正在尝试通过专用代理在 VSTS 上的部署步骤中 运行 "Windows Machine File Copy" 任务。

在阅读 https://docs.microsoft.com/en-us/vsts/build-release/tasks/deploy/windows-machine-file-copy?view=vsts 的文档时,"Source" 参数部分说:

You can use pre-defined system variables such as $(Build.Repository.LocalPath) (the working folder on the agent computer), which makes it easy to specify the location of the build artifacts on the computer that hosts the automation agent.

当我尝试使用那个确切的变量(因为我真的想复制最新的源文件)时:

运行 执行任务时出现以下错误:

[error]Source path 'C:\agent_work\r1\a$(Build.Repository.LocalPath)' does not exist.

2018-04-18T05:52:09.2461155Z ==============================================================================
2018-04-18T05:52:09.2461984Z Task         : Windows Machine File Copy
2018-04-18T05:52:09.2462630Z Description  : Copy files to remote machine(s)
2018-04-18T05:52:09.2463336Z Version      : 2.0.4
2018-04-18T05:52:09.2463945Z Author       : Microsoft Corporation
2018-04-18T05:52:09.2464620Z Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=627415)
2018-04-18T05:52:09.2465332Z ==============================================================================
2018-04-18T05:52:13.1043515Z ##[error]Source path 'C:\agent\_work\r1\a$(Build.Repository.LocalPath)' does not exist.
2018-04-18T05:52:13.1533941Z ##[section]Finishing: Copy files To Server
2018-04-18T05:52:13.1653576Z ##[section]Finishing: Release

我是不是漏掉了什么?

作为背景,我想这样做 Robocopy/WMFC 因为我正在部署一个静态网站,该网站的源代码总数约为 40gigs。我不想先将整个 Build Output 复制到 artifacts 目录,因为这会花费太长时间。我需要比复制 40 GB 数据更快的部署。这是一个遗留网站,我对它的结构方式无能为力。

最终,我试图拉取最新的源代码(没有清理,因为拉取 40 演出太慢)然后执行 RoboCopy /MIRror 以仅将更改的文件复制到另一台机器上的目标 IIS 目录。

根据你的问题,我可以看出你是在基于 C:\agent_work\r1\a\$(Build.Repository.LocalPath) 的版本上执行此操作,其中 r1 是版本。

基于 release variable documentation,$(Build.Repository.LocalPath) 无法发布。

您应该改用发布变量之一,例如 $(System.DefaultWorkingDirectory)\工件名称