2

我有一个项目,该项目在服务器上有一个包含上传文件的文件夹。我没有将它包含在 Web 部署中,因为它非常庞大!

所以我有一个 wpp.targets 文件,它跳过删除该文件夹及其内容(一个重要的考虑因素:-))

但是,我想摆脱手动服务器配置,所以我希望网络部署确保 IIS_USRS 组对 UserMedia 文件夹具有写入权限(所以我永远不必记得检查)

我发现了@sayed-ibrahim-hashimi 的这篇文章,它让我几乎一路走来。但是 MSDEPLOY 在创建 WebDeploy 包时引发错误,抱怨该文件夹不存在以设置 ACL - 而且它不存在于我的本地计算机上......

所以,我的问题是是否可以修改@sayed-ibrahim-hashimi的方法,以便仅在文件夹存在时才能设置 ACL?


我的 wpp.targets 文件:

<?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 to the 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>
4

0 回答 0