12

免责声明:我知道如果我选中“在目标上保留额外文件”复选框,我可以保留文件夹权限,但我不想这样做

也就是说,有没有办法让 Visual Studio 2010 中的一键式 Web 发布保留远程服务器上文件夹的权限?

具体来说,我希望应用程序池帐户对 App_Data 文件夹具有修改权限,但在发布过程中始终会重置权限。

4

1 回答 1

15

By default we will call the Web Deploy SetAcl provider on the App_Data folder, this behavior is controlled by an MSBuild property, IncludeSetAclProviderOnDestination. The default value for this property is true in %ProgramFiles32%\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets. If you want to prevent the SetAcl provider from being called you can just set this property to false when publishing. In order to do this follow these steps.

  1. In the same directory as your project create a file with the name {ProjectName}.wpp.targets (where {ProjectName} is the name of your Web application project)
  2. Inside the file paste the MSBuild content which is below this list
  3. Reload the project in Visual Studio (VS caches the project files in memory so this cache needs to be cleared).

{ProjectName}.wpp.targets

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <IncludeSetAclProviderOnDestination>false</IncludeSetAclProviderOnDestination>
  </PropertyGroup>    
</Project>

Inside of this file you can see that I'm declaring that property and setting it's value to False. After you have this file it will automatically be picked up by our publishing process, both from Visual Studio as well as any publish operations from the command line.

Can you try that out and let me know if you have further issues?

于 2011-07-29T04:18:00.460 回答