12

Disclaimer: I know that I can retain folder permissions if i check the "Leave extra files on destination" checkbox but I don't want to do that.

That said, is there any way to have one-click web publishing in Visual Studio 2010 retain the permissions of a folder on the remote server?

Specifically, I want the app pool account to have modify permissions to the App_Data folder, but the permissions always get reset during the publish process.

Sayed Ibrahim Hashimi
  • 43,864
  • 17
  • 144
  • 178
Lobstrosity
  • 3,928
  • 29
  • 23

1 Answers1

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?

Sayed Ibrahim Hashimi
  • 43,864
  • 17
  • 144
  • 178
  • Nailed it. Thank you, sir. Now, sort of a followup question. To make this work, I have to put a dummy placeholder file in App_Data because there are initially no files in it. (I'm using it as the runtime cache location for a third-party library I'm using.) I don't suppose I can have "leave extra files..." unchecked but somehow tell it to specifically not delete App_Data? – Lobstrosity Jul 29 '11 at 16:18
  • 1
    I think you will have to keep the dummy file there for now :( Sorry. – Sayed Ibrahim Hashimi Jul 29 '11 at 18:31