1

I'm trying to setup a common publish project using the Helix Publishing Pipeline.
When I publish to my local temp directory, it publishes Sitecore Assemblies and also other files like HtmlAgilitypack.dll, Newtonsoft.dll, System.Web.Helpers.dll etc.

Using Visual Studio 2019.

How can I exclude them?
Should the setting be in Local.pubxml or should it be in the .wpp.targets file?

I tried using the commented code in template - AdditionalFilesToRemoveFromTarget, <SitecoreAssembliesToExclude. None worked.

Here are my files:

Local.pubxml

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <PublishUrl>C:\out\Stratum</PublishUrl>
    <LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <DeleteExistingFiles>False</DeleteExistingFiles>
    
  </PropertyGroup>
<Target Name="EnsurePublishUrl" BeforeTargets="Build">
    <Error Condition="'$(PublishUrl)' == ''" Text="Please configure a publishUrl in $(MSBuildProjectName)/Properties/PublishProfiles/Local.pubxml. You may need to reload your solution to apply the change.
Auto-publish can be disabled in $(MSBuildProjectName).wpp.targets." />
  </Target>  
</Project>

Stratum.Publish.Website.wpp.targets

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <ItemGroup>    
    <SitecoreAssembliesToExclude Include="@(SitecoreAssemblies)" />
  </ItemGroup>
  <PropertyGroup>
    <EnableAutoPublish>false</EnableAutoPublish>

    <AutoPublish Condition="'$(AutoPublish)' == '' and '$(EnableAutoPublish)' == 'true' and '$(Configuration)' == 'Debug' and '$(BuildingInsideVisualStudio)' == 'true' and '$(PublishProfile)' != ''">true</AutoPublish>

    <AutoPublishDependsOn Condition="'$(AutoPublish)' == 'true'">
      $(AutoPublishDependsOn);
      WebPublish
    </AutoPublishDependsOn>
  </PropertyGroup>

  <Target Name="AutoPublish" AfterTargets="Build" DependsOnTargets="$(AutoPublishDependsOn)">
  </Target>

</Project>

packages.config

<packages>
  <package id="RichardSzalay.Helix.Publishing.WebRoot" version="1.5.6" targetFramework="net48" />
  <package id="Sitecore.Assemblies.Platform" version="10.3.0" targetFramework="net48" />
</packages>
2

3 Answers 3

2

This worked for me.

MyProject.Publish.wpp.targets:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   
           
  <ItemGroup>
    <SitecoreAssembliesToExclude Include="@(SitecoreAssemblies)" />
  </ItemGroup>

  <ItemGroup>
    <ExcludeFromPackageFiles Include="bin\Sitecore.*.dll;" Exclude="bin\Sitecore.Commerce.Proxy.dll"/>
      
    
    <ExcludeFromPackageFiles Include="bin\*.dll.config;
                             bin\Stratum.Publish.Website.dll;
                             bin\Stratum.Publish.Website.pdb;
                             bin\de;                             
                             bin\Scriban.dll;
                             bin\Spatial4n.Core.dll;
                             bin\Newtonsoft.Json.dll;
                             bin\Newtonsoft.Json.Bson.dll;
                             bin\Microsoft.OData.Client.dll;
                             bin\AjaxMin.dll;
                             bin\Microsoft.Extensions.Caching.StackExchangeRedis.dll;
                             bin\HtmlAgilityPack.dll;
                             bin\Microsoft.Bcl.AsyncInterfaces.dll;
                             bin\Microsoft.Extensions.DependencyInjection.Abstractions.dll;
                             bin\Microsoft.Extensions.DependencyInjection.dll;
                             bin\Microsoft.Web.Infrastructure.dll;
                             bin\System.Web.Helpers.dll;
                             bin\System.Web.Mvc.dll;
                             bin\System.Web.Razor.dll;
                             bin\System.Web.Webpages.Deployment.dll;
                             bin\System.Web.Webpages.dll;
                             bin\System.Web.Webpages.Razor.dll;
                             " />    
  </ItemGroup>
   
</Project>
1

You can do a change in your .wpp.targets file by adding this.

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="ExcludeSitecoreAssemblies" AfterTargets="Compile">
    <ItemGroup>
      <ExcludeFromPackageFiles Include="@(SitecoreAssemblies -> 'bin\%(Filename)%(Extension)')" />
      <ExcludeFromPackageFiles Include="@(SitecoreAssemblies -> 'bin\%(Filename).pdb')" />
      <ExcludeFromPackageFiles Include="@(SitecoreAssemblies -> 'bin\%(Filename).xml')" />
    </ItemGroup>
  </Target>
</Project>

This configuration will make sure to exclude all files that are listed in the the referenced assembly list from deployment

For more details follow this one.

https://community.sitecore.com/community?id=community_blog&sys_id=fcb2236d1b8370d0b8954371b24bcbdb

Hope this helps.

1

You can also reference a list of assemblies that should be excluded into a CSV file.

<ItemGroup>
  <!-- Requires NuGet reference to Sitecore.Assemblies.Platform or another Assemblies package -->
  <SitecoreAssembliesToExclude Include="@(SitecoreAssemblies)" />

  <!-- Assembly lists -->
  <SitecoreAssemblyListsToExclude Include="Assembly Lists\Sitecore.Platform.Assemblies 9.0.1 rev. 171219.csv" />
  <SitecoreAssemblyListsToExclude Include="Assembly Lists\Sitecore.XConnect.Platform.Assemblies 9.0.1 rev. 171219.csv" />

  <!-- Or individual assemblies -->
  <SitecoreAssembliesToExclude Include="Sitecore.Kernel.dll" />
</ItemGroup>>

You may follow this blog post to see how that CSV file can be generated. https://konabos.com/blog/sxa-platform-assembly-lists

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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