Search code examples
visual-studio-2015webdeploy

Exclude destination files when publishing project from visual studio


so just a quick overview of my setup. I'm using visual studio 2015, the project is an mvc web application and im using web deploy to publish the site.

Currently i have these options set in my publish profile

publish profile

So essentially my problem is i have some folders and files present on the production environment that i would like to keep, but at the same time i would like to delete other files that are no longer present in my project.

For instance, we keep the database connection in a separate file "web.connectionstrings.config" which is in the root of the site. This file is in my project but with content set to none (this is because the file doesn't get checked into source control and therefore i don't want to publish it). But because of that it also wants to delete it on the destination server.

Another example is the logs folder. I don't want to delete this on the production server, but because this folder is autogenerated and not in my project, it wants to delete it.

I've followed this link https://www.asp.net/web-forms/overview/deployment/advanced-enterprise-web-deployment/excluding-files-and-folders-from-deployment

However i just get the following error

Web deployment task failed. (Unrecognized skip directive 'skipaction'. Must be one of the following: "objectName," "keyAttribute," "absolutePath," "xPath," "attributes..")

i have also followed this answer https://stackoverflow.com/a/29688263/5878196

but this generates the same error as above.

I have tried editing the .csproj file directly with the following lines

<ExcludeFilesFromDeployment> Web.ConnectionStrings.config;Web.secrets.config; </ExcludeFilesFromDeployment> <ExcludeFoldersFromDeployment> logs </ExcludeFoldersFromDeployment>

but this just seems to get ignored.

just for reference i have also tried this package https://github.com/ligershark/publish-ignore

again anything i do just seems to get ignored.

I just wondered if anyone had any suggestions really or a better way of doing it. Thanks


Solution

  • Resolved this issue by deploying the Web Project via AppVeyor which has skip files/folders built into the functionality.