views:

145

answers:

1

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

A: 

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.

Workarounds :

  • The simple one : Give the right to your build agent
  • 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.

madgnome