Windows 如何在通过SMB与TeamCity上传文件之前删除远程文件夹中的所有内容

Windows 如何在通过SMB与TeamCity上传文件之前删除远程文件夹中的所有内容,windows,teamcity,smb,Windows,Teamcity,Smb,我正在Windows计算机上运行TeamCity服务器和代理。构建过程中的最后一步是通过SMB将bin/release文件上传到另一台服务器上的共享Windows文件夹 在上传新版本之前,我需要删除远程服务器上的所有文件,但无法找到方法 我在SMB upload runner中没有看到任何这样的选项 是的,您是正确的,应该作为构建步骤下的步骤添加,我更喜欢类似这样的powershell命令 robocopy \\%WebServer1%\%SourceFolder% \\%WebServer1%

我正在Windows计算机上运行TeamCity服务器和代理。构建过程中的最后一步是通过SMB将bin/release文件上传到另一台服务器上的共享Windows文件夹

在上传新版本之前,我需要删除远程服务器上的所有文件,但无法找到方法


我在SMB upload runner中没有看到任何这样的选项

是的,您是正确的,应该作为构建步骤下的步骤添加,我更喜欢类似这样的powershell命令

robocopy \\%WebServer1%\%SourceFolder% \\%WebServer1%\%DestinationFolder% /E /PURGE /IS /COPY:DT /R:1 /W:2
RMDir /S "%WebServer1%\%SourceFolder%

Where, 
    /E - Copies sub directories
    /PURGE - Deletes destination files and directories that no longer exist in the source
    /COPY:DT - Specifies the file properties to be copied, in this case it copies Data and Timestamps
    /R:1 - Specifies the number of retries on failed copies, in this case it is 1
    /W:2 - Specifies the wait time between retries, in seconds, in this case it is 2 seconds
    /s - Includes subdirectories
一旦robocopy成功,RmDir将删除源目录

如果需要直接删除文件,而不是复制然后删除,可以使用Move

移动参考-

我个人更喜欢复制和删除