Reputation:
Good afternoon,
say is it possible to provide credentials (username/pw) for file or folder activities (e.g. removecontent) with the MSBuild Extension Pack? As in.. the build user is not necessary the one I want to use to deleted/work with on certain folders/files I need to modify/delete (e.g. remotely on UNC shares).
Is this doable? I am somewhat lost :-/
Cheers and thanks,
-J
Upvotes: 4
Views: 1195
Reputation: 50000
RemoveContent
task and the other folder tasks of MSBuild Extension pack use DirectoryInfo
internally.
To access remote folder DirectoryInfo
handles UNC path
, the problem is that you can't put the credential in a UNC path
. So you can't do what you want directly using only RemoveContent
task.
The better : Map the folder to a network drive and use this network drive in your MSBuild task. This can be done with MSBuild Exec
task and 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 MSBuild custom task doing what you want and that takes credential as parameters.
Upvotes: 2