具有PackageLocation的MsBuild Deploy删除文件权限

问题描述 投票:4回答:3

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

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

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

msbuild web-deployment
3个回答
0
投票

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

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

0
投票

添加MSBuild .proj文件:

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

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


0
投票

如果您想让您的网站可以访问文件夹,您可以将以下代码段放在.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,所以你的里程可能因这个特殊方面而有所不同。

© www.soinside.com 2019 - 2024. All rights reserved.