6

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

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

("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

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

As that was suggested in different posts when Googling.

Does anyone have the solution for this?

4

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">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <DeleteExistingFiles>False</DeleteExistingFiles>
    <ExcludeFilesFromDeployment>
        bin\Sitecore.*.dll;
    </ExcludeFilesFromDeployment>
  </PropertyGroup>
</Project>

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. – Morten Ljungberg Jan 10 '18 at 8:47
6

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. – Radenko Zec Nov 22 at 8:06
2

Try this one:

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

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? – Morten Ljungberg 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.