【问题标题】:Copying Source Directory to a shared network folder within a TFS Build将源目录复制到 TFS 构建中的共享网络文件夹
【发布时间】:2018-08-02 18:56:59
【问题描述】:

我正在尝试将 TFS 集合中我的源文件夹中的所有文件复制到我设置的 VM。 VM 有一个共享文件夹,我可以通过键入\\*IPAddress*\share(其中 IPAddress 是 VM 的 IP)在文件资源管理器中访问。

  • 我尝试通过在 TFS 2015 中添加“复制文件”构建任务来复制源文件夹。
  • Source Folder 部分中,我添加了要复制的文件夹。
  • Contents 部分中,我将其保留为** 以获取Source Folder 中的每个文件
  • Target Folder 中,我已将可以导航到的地址放入文件资源管理器中:\\*IPAddress*\share(其中 IPAddress 是 VM 的 IP)

当我将构建排队并运行它时,我收到以下错误:

Unable to create directory '\\*IPAddress*\share'. Unable to verify the directory exists: '\\*IPAddress*\share'. If directory is a file share, please verify the share name is correct, the share is online, and the current process has permission to access the share.

当我将鼠标悬停在目标文件夹旁边的小“I”上时,它表明它可以是 UNC 路径,所以我知道我可以复制文件,但我不确定我是否引用了正确共享文件夹。

我将如何引用它?可能还存在问题的一件事是,当我从文件资源管理器导航到共享时,我必须输入凭据才能访问共享文件夹,因此它可能因此无权访问共享。

【问题讨论】:

  • 为此使用Windows Machine File Copy 任务,而不是Copy Files。它将为您处理身份验证、映射共享和复制文件。

标签: tfs tfsbuild unc


【解决方案1】:

测试和Windows Machine File Copy 任务对我有用,提供访问共享路径的凭据。

对于Copy Files 任务,您可以尝试为构建代理服务帐户(您在部署代理期间指定)授予读取写入权限,然后再试一次。

此外,您还可以创建脚本来复制文件,然后添加命令行或 PowerShell 任务来运行脚本。

例如,您可以使用下面的 PowerShell 脚本来复制源文件,并提供特定的用户名和密码:

$Source = $env:BUILD_SOURCESDIRECTORY
$Dest   = "\\172.17.16.115\CopyTest"
$Username = "domain\username"
$Password = ConvertTo-SecureString "PasswordHere" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential($Username, $Password)
New-PSDrive -Name J -PSProvider FileSystem -Root $Dest -Credential $mycreds -Persist
Copy-Item -Path $Source -Recurse -Force -Destination $Dest 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-18
    • 2013-11-14
    • 2021-12-18
    • 1970-01-01
    相关资源
    最近更新 更多