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.