Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I stop Visual Studio's Web Publish from removing write permissions from my target web site?

I have a web app (actually Orchard CMS) that I am customizing and I want to push directl from my build server to my hosting provider, using Web Publishing aka MSDeploy.

The problem is, when I publish the site (from Visual Studio, haven't tried it from the build server yet) it removes the write permission from the target web site, which makes Orchard instantly fall over because it can no longer access its database (etc).

We can debate the wisdom of this, but the bottom line is that Orchard requires write access, and web publishing insists on removing that access, which breaks the site. Not good. I have to log in to the service provider's control panel and reset the permissions each time I publish, which kind of makes the process less than automatic.

So, how do I get Web Publishing to leave the ACLs alone? I can't find any settings for this in the solution anywhere.

like image 817
Tim Long Avatar asked May 27 '13 23:05

Tim Long


People also ask

How do I change publish settings in Visual Studio?

Import the publish settings in Visual Studio and deployClick New or Create new profile. Select the option to import a profile. In the Publish dialog box, click Import Profile. Navigate to the location of the publish settings file that you created in the previous section.

Where are Visual Studio publish profiles stored?

Publish profile files are named <profilename>. pubxml and are located in the PublishProfiles folder. The PublishProfiles folder is under Properties in a C# web application project, under My Project in a VB web application project, or under App_Data in a web site project.

Can't connect to remote server web deploy?

This error indicates that you cannot connect to the server. Make sure the service URL is correct,firewall and network settings on this computer and on the server computer are configured properly,and the appropriate services have been started on the server.


2 Answers

You can add turn off the ACL setting functionality by adding this to the .pubxml file:

    <IncludeSetACLProviderOnDestination>False</IncludeSetACLProviderOnDestination>

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

The article also mentions you can change this for all publish configurations via a local .wpp.targets file. Make sure to consider that option if you use multiple publish configurations

like image 57
tdykstra Avatar answered Oct 05 '22 03:10

tdykstra


In some cases you may find that after publishing a project using Web Deploy the ASPNet IUSR cannot write to the root directory or any files within it (except App_Data).

By default Web Deploy sets the ACL of the ASPNet IUSR to read only. To prevent this from causing problems when you publish your application, you will need to locate the project file and make some changes. The project file will end with the extension .vbproj for applications written in Visual Basic or .csproj for applications written in C#. In the project file find:

<propertygroup condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' "></propertygroup>

and change it to:

<propertygroup condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
<includesetaclproviderondestination>False</includesetaclproviderondestination>
</propertygroup>

This will ensure that ACL is not modified by Web Deploy.

If you already deployed to a 3rd party hosting provider, you may need to contact them to get your permissions reset before doing another deployment.

like image 37
Paul Devenney Avatar answered Oct 05 '22 02:10

Paul Devenney