I am trying to find out how to exclude files when using the publishing feature in VS (2017 to be exact).

The documentation is not great, but it seems adding

    <Content Update="file name">

("file name" was set to web.config, but also folders and other files were tested)

to the profile.pubxml under <project> should do the trick, but it doesn't :(

I have tried changing "Never" to "false" as VS intelisense seems to suggest that.

I have also tried

    <Content Update="file name" CopyToPublishDirectory="Never" />

As that was suggested in different posts when Googling.

Does anyone have the solution for this?

  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Mark Cassidy
    Jan 10 '18 at 17:45

You could also add a property group called ExcludeFilesFromDeployment to your profile.pubxml publishing profile. I have mine setup like this:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />

To make sure non of the Sitecore binaries are deployed.

Also - in your VS Project you can just set the build action to none in the properties of the files. That will affect the project file, so it will apply to all publishing profiles, not just the one you are editing.

  • 1
    Be careful with this one, esp is you are referencingSitecore.Support.*.dll on your projects and expecting them to be deployed :)
    – jammykam
    Jan 9 '18 at 15:53
  • That works! Where have you found that element (ExcludeFilesFromDeployment)? I have not found that in any of the limited documentation I have read through ;) And it does not appear as an option in the intellisense. Jan 10 '18 at 8:47

Although this is off-topic, this is a common issue in Sitecore for those who are experimenting with Helix/Habitat. Anyway, you can also achieve this on the VS UI which essentially results to the project file snippet Anton has shown above. Just choose Properties on the file you want to not process and change the Build Action to None.

enter image description here

  • Not working my friend. Nov 22 '19 at 8:06

Try this one:

  <None Update="file name" CopyToPublishDirectory="Never" />

It will change build action from content to none and will exclude file from publishing.

  • I tried this as well, without any luck. Is it working for you? Jan 9 '18 at 19:06
  • 1
    You have to do this in the csproj file.
    – Richard Seal
    Jan 10 '18 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.