【发布时间】:2017-10-19 20:22:23
【问题描述】:
该项目是一个使用 VS2017 和(本地)TFS2017 编码和构建的 MVC 网站。构建定义当前正在工作并在签入时发布到暂存位置。
下面的 PowerShell 脚本源自 David Kittle's website,正在使用,但它每次都会上传所有文件。我使用 cmets 对清单进行了缩写,以专注于我想寻求帮助/指导的脚本部分。
# Setup the FTP connection, destination URL and local source directory
# Put the folders and files to upload into $Srcfolders and $SrcFiles
# Create destination folders as required
# start file uploads
foreach($entry in $SrcFiles)
{
#Create full destination filename from $entry and put it into $DesFile
$uri = New-Object System.Uri($DesFile)
#NEED TO GET THE REMOTE FILE DATA HERE TO TEST AGAINST THE LOCAL FILE
If (#perform a test to see if the file needs to be uploaded)
{ $webclient.UploadFile($uri, $SrcFullname) }
}
在上面脚本的最后几行中,我需要确定源文件是否需要上传。我假设我可以检查时间戳来确定这一点。所以;
如果我的假设是错误的,请告知检查所需上传的最佳方法。
如果我的假设是正确的,我如何 (1) 从远程服务器检索时间戳,然后 (2) 对本地文件进行检查?
【问题讨论】:
标签: powershell ftp webclient continuous-delivery