Generating Assembly Lists for SXA (or anything) to exclude during deployment

Kamruz Jaman - Solution Architect

22 Mar 2021

Share on social media

Just a super quick post with a super small, but hopefully useful script.

For those of you that may be following Helix principles in your project builds, you might be aware of the Helix Publishing Pipeline by Richard Szalay. The project adds a number of useful MSBuild extensions which makes publishing multiple web projects as a single unit much simpler, with content, configs, views, configs etc from all projects being collected for deployment. This is not something that works easily in a regular Visual Studio solution.

There is another useful feature to ease deployment pain: the ability to exclude Sitecore assemblies from the build output. Typically in Sitecore builds you do not want to include the out of the box DLLs in order to reduce deployment bloat and it gives you a really clean deployment package.

You can exclude Sitecore assemblies either individually, from Sitecore Assemblies NuGet packages (available on the sc-packages feed, e.g. Sitecore.Assemblies.Platform) or from assembly lists (csv files available for each release, available from Sitecore Downloads site).

However, if you are using a module like Sitecore Experience Accelerator (SXA) then the Assemby List is unfortunately not available on the Downloads site, and the MyGet site only includes the Assembly lists for Sitecore 10+ (list of available packages can be found in this article) but however their an error with these lists and they do not currently include any packages.

We can however generate our list with this handy script. [CmdletBinding()] Param ( [string] $SourceFolder = ".\", [string] $TargetFile = "SXA.Platform.Assemblies.csv" ) Write-Host "Generating Assembly list to $TargetFile ..." -ForegroundColor Yellow Get-ChildItem -Path $SourceFolder -Recurse -Include *.dll | % { $_.VersionInfo } | ` Select-Object -Property @{N='Filename'; E={$_.OriginalFilename}}, ` @{N='Version'; E={$_.FileVersion}}, ` @{N='FileVersion';E={$_.ProductVersionRaw}}, ` @{N='InfoVersion';E={$_.ProductVersion}} | ` Export-Csv $TargetFile -NoTypeInformation "sep=,`n" + (Get-Content -Path $TargetFile -Raw).replace('"','') | Set-Content -Path $TargetFile Write-Host "Done!" -ForegroundColor Green The code could be a little simpler with some of the new options added in PowerShell 7.0 (such as the UseQuotes flag), but the above will work against the more common version 5.1.

Simply download the SXA installation package, unzip the files and run the script against the extract bin folder.

To save you all an extra step, the assembly list for all SXA versions back to 1.6 can found in this repo: https://github.com/konabos/SXA.Platform.Assemblies

If you have multiple csv files as exclusion lists then you can use a wildcard to reference them all in your .wpp.targets file. <ItemGroup> <SitecoreAssemblyListsToExclude Include="..\..\AssemblyLists\*.csv" /> </ItemGroup> Happy Experience Accelerating.

Sign up to our newsletter

Share on social media

Kamruz Jaman

Kamruz is a 11-time Sitecore MVP who has worked with the Sitecore platform for more than a decade and has over 20 years of development and architecture experience using the Microsoft technology stack. Kamruz is heavily involved in the Sitecore Community and has spoken at various User Groups and Conferences. As one of the managing partners of Konabos Inc, Kamruz will work closely with clients to ensure projects are successfully delivered to a high standard.


Subscribe to newsletter