I am trying to copy files to a remote server, the account I am running my build server doesn't have permissions though. How can I do it using different credentials?
It's best to create a quick extension of CallTarget task that uses Impersonator by Uwe Keim, like this:
public class Impersonate : CallTarget
{
public string Domain { get; set; }
[Required]
public string UserName { get; set; }
[Required]
public string Password { get; set; }
public override bool Execute()
{
using (new Impersonator(this.UserName, this.Domain, this.Password))
{
return base.Execute();
}
}
}
Then call will look like this:
<Target Name="DoSms">
<....>
</Target>
<Target Name="Impersonate">
<Impersonate Targets="DoSms" UserName="username" Password="password" Domain="domain"/>
</Target>
Try Exec task to execute RunAs.exe which would run the xcopy.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With