Aleš Hriberšek
Aleš Hriberšek

Reputation: 59

TFS publishing on shared network path with credentials

What process should I use for publishing my App on a shared network path which requires a domain username and password.

I cannot access the server, so "Windows Machine File Copy" isnt an option. I just have a shared folder access on this server. I also cannot use "Publish Build Artifacts" because there arenoo credentials options there.

Any tip? Thanks

Upvotes: 2

Views: 1493

Answers (1)

Andy Li-MSFT
Andy Li-MSFT

Reputation: 30412

You just need to grant the correct permission for the agent service account to access the shared network path, then you can use the task "Publish Build Artifacts" or "Copy and Publish Build Artifacts" with selecting File Share as the Artifact Type, then enter the shared network path something like \\myshare\\xxx

However if you want to copy files with another user, then you can try below steps:

1.- Grant the correct permission (at least Write permission) for your account to access the shared network path.

2.-Create a PowerShell script to copy files to the target machine (Reference below sample):

Param(
  [string]$source = "SourceFolder",
  [string]$dest ="\\myshare\SharedNetworkPath"
)
$Username = "Domain\username"
$Password = ConvertTo-SecureString "Password" -AsPlainText -Force

$cred = New-Object System.Management.Automation.PSCredential($Username,$password)

Copy-Item $source -Destination $dest -Recurse -ErrorAction SilentlyContinue -Credential $cred

3.- Add a PowerShell task to run the script in build definition.

Please note that, if you cannot access the server with your domain username and password, then you cannot publish on the shared network path.

enter image description here

Upvotes: 1

Related Questions