分类
开发工具

使用vs2012的web deploy发布文件写权限丢失的问题

最近用美国虚拟主机试了一下vs2012的新功能web deploy。其实和vs2010的ftp发布类似更先进,更适合发布web应用类型的项目。但是随即发现一个问题,每次用web deploy发布之后,会丢失web目录的“写”权限。

于是我就不淡定了,首先找主机商arvixe发邮件,技术支持给我回了个:

Hello,

If the permissions are getting altered after deployment then I would request you to please refer :
http://blog.arvixe.com/when-publishing-an-application-using-visual-studio-2012-file-permissions-are-altered/

 

这是他们的博客,有很多技术解答,可是我怎么翻通过各国代理都无法打开这个文章。。。看关键词我想应该不是他们控制面板的问题,于是在网上查了下类似的情况,终于在微软的官网修改pubxml教程上找到了原因。

http://msdn.microsoft.com/en-us/library/ff398069.aspx

For example, suppose that you want to disable the default setACL behavior of Visual Studio deployment. By default, Visual Studio sets read permissions on the root folder of the destination site and write permissions on the App_Data folder. If you know that the default permissions on folders are correct and don’t need to be set, you can disable this behavior for a specific publish profile by adding the following XML to the publish profile file:

修改pubxml的情况,例如,如果你想禁用的Visual Studio部署时的默认SETACL行为。默认情况下,Visual Studio发布的ACL设定是将目标站点的根目录设置为只读权限,对App_Data文件夹设置克写权限。如果你需要这样的文件权限就不需要修改设置,不然,请修改pubxml:您可以在发布配置文件里加入这段代码禁用此ACL设定:

<IncludeSetACLProviderOnDestination>False</IncludeSetACLProviderOnDestination>


完整的pubxml应该是:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <IncludeSetACLProviderOnDestination>False</IncludeSetACLProviderOnDestination>
    <WebPublishMethod>Package</WebPublishMethod>
    <LaunchASiteUrlAfterPublish>False</LaunchASiteUrlAfterPublish>
    <SiteUrlToLaunchAfterPublish />
    <MSDeployServiceURL />
    <DeployIisAppPath />
    <RemoteSitePhysicalPath />
    <AllowUntrustedCertificate>False</AllowUntrustedCertificate>
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <DeployAsIisApp>True</DeployAsIisApp>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <UserName />
    <SavePWD>True</SavePWD>
    <PublishDatabaseSettings>
      <!— this section omitted to keep the example short -->
    </PublishDatabaseSettings>
  </PropertyGroup>
</Project>