【问题标题】:MsBuild Deploy with PackageLocation drop file permissions具有 PackageLocation 放置文件权限的 MsBuild Deploy
【发布时间】:2012-02-24 15:18:47
【问题描述】:

我在 TFS 中有一个 MsBuild Build,它正在发布一个 Web zip 包。 这是我正在使用的命令行:

/t:Build;Package 
/p:DeployOnBuild=true;Configuration=Release;
DeployTarget=Package;PackageLocation=\\xxx\MyApp.zip

它工作正常,并且在 web.config 中也按预期替换了参数。 我面临的唯一问题是应用于包文件的权限。 现在文件被部署到: * \myshare\myapp\ * 并且该文件夹设置了权限: 每个人:完全控制 文件夹内的包有权限: TFSAdmin:完全控制 没有别的,所以我无法打开或复制它......有什么办法可以避免吗?

【问题讨论】:

    标签: msbuild web-deployment


    【解决方案1】:

    到目前为止,如果没有解决方法,似乎无法解决问题。 通过在构建过程结束时在工作流中执行批处理文件,我找到了一种简单易行的解决方法。 在批处理文件中,我使用非常旧的 ICACLS 重新设置权限:

    ICACLS \\xxx\MyPackage.zip /GRANT Everyone:F
    ICACLS \\xxx\MyPackage.zip /GRANT Users:F
    

    【讨论】:

    • 我更喜欢使用 /reset 开关重新继承权限。
    【解决方案2】:

    在 MSBuild .proj 文件中添加:

    <Exec Command="icacls "\\xxx\MyApp.zip" /grant User:F" ContinueOnError="true" />
    

    一系列简单的权利: F - 完全访问 M - 修改访问 RX - 读取和执行访问 R - 只读访问 W - 只写访问

    【讨论】:

      【解决方案3】:

      如果您想让您的网站可以访问文件夹,您可以将以下 sn-p 放在 .csproj 最底部的“PostBuild”事件中(您需要通过文本手动编辑 .csproj 文件编辑):

      <Target Name="AfterBuild">
        <!-- grant everyone the modify right recursively even for files and folders created dynamically in the future -->
        <!-- note the use of (OI) and (CI) flags which stand for object inherit & container inherit    these flags      -->
        <!-- indicate that subordinate containers will inherit the same access control element or ace   this means that -->
        <!-- files and folders created in the future within the targeted folder will get the same permissions            -->
      
        <Exec Command="  icacls   &quot;.\Logs&quot;              /grant      Users:(CI)(OI)M  /T  "  ContinueOnError="true" />σ
        <Exec Command="  icacls   &quot;.\Logs&quot;              /grant  IIS_IUSRS:(CI)(OI)M  /T  "  ContinueOnError="true" />
      
      </Target>
      

      旁注:如果您使用 Visual Studio 的发布/部署远程服务器功能来部署您的网站,那么不用说文件夹权限可能不会被保留,您将不得不使用某种安装后脚本来重新应用它们(可能使用 'icacls' 方法再次显示在这里)。这种安装后脚本可能应该是 WebDeploy 的一部分——虽然我自己没有使用过 WebDeploy,所以你的里程可能会在这个特定方面有所不同。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-07-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-17
        相关资源
        最近更新 更多