MSBuild Extension Pack: Credentials for File / Folder Tasks?

Good afternoon,

Tell me, is it possible to provide credentials (username / pw) for actions with files or folders (for example, removeecontent) with the extension MSBuild? As in .. the assembly user does not need the one that I want to use to delete / work with certain folders / files that I need to change / delete (for example, remotely on UNC shares).

Is this doable? I am somewhat lost: - /

Greetings and thanks

-J

+4
source share
1 answer

RemoveContent , and in other tasks of the MSBuild extension package folder, use DirectoryInfo internally.

To access the remote DirectoryInfo handle UNC path , the problem is that you cannot put credentials in the UNC path . Thus, you cannot do what you want directly using only the RemoveContent task.

Workarounds:

  • Simple: entitle your build agent
  • The better: copy the folder to the network drive and use this network drive in your MSBuild task. This can be done using the MSBuild Exec task and the net command.

     <Target Name="MapAndRemove"> <!-- Map the remote folder with credential --> <Exec Command="net use Z: \\ServerName\ShareName\YourFolder {Password} /user:{User} /yes"/> <!-- Remove content in remote folder using network drive --> <MSBuild.ExtensionPack.FileSystem.Folder TaskAction="RemoveContent" Path="Z:\"/> </Target> 
  • The harder: write a custom MSBuild task, doing what you want and that takes credentials as parameters.

+2
source

All Articles