msbuild - Using webdeploy to set ACL on a folder only if that folder exists -


i have project has folder on server contains uploaded files. don't include in web deploy because it's massive!

so have wpp.targets file skips deleting folder , contents (an important consideration :-))

however, want move away manual server configuration i'd web deploy ensure iis_usrs group has write permission on usermedia folder (so never have remember check)

i found this article @sayed-ibrahim-hashimi gets me way there. msdeploy throws error while creating webdeploy package complaining folder not present set acl on - , isn't present on local machine...

so, question whether possible amend @sayed-ibrahim-hashimi's method can set acl if folder exists?


my wpp.targets file:

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">   <target name="setupcustomacls" aftertargets="addiissettingandfilecontentstosourcemanifest">     <itemgroup>       <msdeploysourcemanifest include="setacl">         <path>$(_msdeploydirpath_fullpath)\usermedia</path>         <setaclaccess>read,write</setaclaccess>         <setaclresourcetype>directory</setaclresourcetype>         <additionalprovidersettings>setaclresourcetype;setaclaccess</additionalprovidersettings>       </msdeploysourcemanifest>     </itemgroup>   </target>    <target name="declarecustomparameters" aftertargets="addiisandcontentdeclareparametersitems">     <itemgroup>       <msdeploydeclareparameters include="usermediasetaclparam">         <kind>providerpath</kind>         <scope>setacl</scope>         <match>^$(_escaperegex_msdeploydirpath)\\usermedia</match>         <description>add write permission usermedia folder.</description>         <defaultvalue>{$(_msdeployparameternameforcontentpath)}/usermedia</defaultvalue>         <value>$(_destinationcontentpath)/usermedia</value>         <tags>hidden</tags>         <priority>$(vssetaclpriority)</priority>         <excludefromsetparameter>true</excludefromsetparameter>       </msdeploydeclareparameters>     </itemgroup>   </target>    <propertygroup>     <onbeforepackageusingmanifest>addcustomskiprules</onbeforepackageusingmanifest>   </propertygroup>   <propertygroup>     <usemsdeployexe>true</usemsdeployexe>   </propertygroup>    <target name="addcustomskiprules">     <itemgroup>       <msdeployskiprules include="skipusermediafiles">         <skipaction>delete</skipaction>         <objectname>filepath</objectname>         <absolutepath>usermedia$</absolutepath>         <xpath></xpath>       </msdeployskiprules>       <msdeployskiprules include="skipusermediafolder">         <skipaction>delete</skipaction>         <objectname>dirpath</objectname>         <absolutepath>usermedia$</absolutepath>         <xpath></xpath>       </msdeployskiprules>       <msdeployskiprules include="skipappfiles">         <skipaction>delete</skipaction>         <objectname>filepath</objectname>         <absolutepath>apps$</absolutepath>         <xpath></xpath>       </msdeployskiprules>       <msdeployskiprules include="skipappfolder">         <skipaction>delete</skipaction>         <objectname>dirpath</objectname>         <absolutepath>apps$</absolutepath>         <xpath></xpath>       </msdeployskiprules>     </itemgroup>   </target> </project>