This post will show how to extend the SIFLess uninstall scripts for an instance that includes Sitecore Experience Commerce 9.
I have been playing around with Sitecore Experience Commerce 9 quite a bit lately. I was able to take part in the early access program and now with the general release I’ve installed and uninstalled it quite a few times. I have also been using SIFLess to install and uninstall Sitecore 9 base instances. Naturally, I felt the need to extend the uninstall scripts to include bits of Commerce that would otherwise be left over.
First, we need to create a new SIF (un)install JSON config file:
| { | |
| "Parameters": { | |
| "SolrUrl": { | |
| "Type": "string", | |
| "DefaultValue": "https://localhost:8989/solr", | |
| "Description": "The Solr instance url." | |
| }, | |
| "SolrRoot": { | |
| "Type": "string", | |
| "DefaultValue": "c:\\solr-6.6.2", | |
| "Description": "The file path to the Solr instance." | |
| }, | |
| "CorePrefix": { | |
| "Type": "string", | |
| "DefaultValue": "xp0", | |
| "Description": "The prefix for each of the created indexes." | |
| }, | |
| "SqlServer": { | |
| "Type": "string", | |
| "DefaultValue": ".\\SQLSERVER", | |
| "Description": "The Commerce Engine database server name." | |
| }, | |
| "SqlAdminUser": { | |
| "Type": "string", | |
| "DefaultValue": "sa", | |
| "Description": "The Sql admin user account to use when installing databases." | |
| }, | |
| "SqlAdminPassword": { | |
| "Type": "string", | |
| "DefaultValue": "12345", | |
| "Description": "The Sql admin password to use when installing databases." | |
| }, | |
| "CommerceServicesDbName": { | |
| "Type": "string", | |
| "DefaultValue": "SitecoreCommerce9_SharedEnvironments", | |
| "Description": "The Commerce Engine database name." | |
| }, | |
| "CommerceServicesGlobalDbName": { | |
| "Type": "string", | |
| "DefaultValue": "SitecoreCommerce9_Global", | |
| "Description": "The Commerce Engine global database name" | |
| }, | |
| "CommerceServicesPostfix": { | |
| "Type": "string", | |
| "DefaultValue": "Sc9", | |
| "Description": "The Commerce Engine postfix for services names" | |
| }, | |
| "SitesRoot": { | |
| "Type": "string", | |
| "DefaultValue": "C:\\inetpub\\wwwroot\\", | |
| "Description": "The parent directory where commerce sites were installed" | |
| }, | |
| "SitecoreBizFxName": { | |
| "Type": "string", | |
| "DefaultValue": "SitecoreBizFx", | |
| "Description": "Sitecore BizFX site name" | |
| }, | |
| "SitecoreIdentityServerName": { | |
| "Type": "string", | |
| "DefaultValue": "SitecoreIdentityServer", | |
| "Description": "Sitecore Identity Server name" | |
| } | |
| }, | |
| "Variables": { | |
| "Solr.FullRoot": "[joinpath(parameter('SolrRoot'), 'server', 'solr'))]", | |
| "CatalogCore": "[concat(parameter('CorePrefix'), '_CatalogItemsScope')]", | |
| "CustomersCore": "[concat(parameter('CorePrefix'), '_CustomersScope')]", | |
| "OrdersCore": "[concat(parameter('CorePrefix'), '_OrdersScope')]", | |
| "CommerceOps": "[concat('CommerceOps_', parameter('CommerceServicesPostfix'))]", | |
| "CommerceShops": "[concat('CommerceShops_', parameter('CommerceServicesPostfix'))]", | |
| "CommerceAuthoring": "[concat('CommerceAuthoring_', parameter('CommerceServicesPostfix'))]", | |
| "CommerceMinions": "[concat('CommerceMinions_', parameter('CommerceServicesPostfix'))]", | |
| "CommerceOpsPhysicalPath": "[concat(parameter('SitesRoot'), variable('CommerceOps'))]", | |
| "CommerceShopsPhysicalPath": "[concat(parameter('SitesRoot'), variable('CommerceShops')))]", | |
| "CommerceAuthoringPhysicalPath": "[concat(parameter('SitesRoot'), variable('CommerceAuthoring')))]", | |
| "CommerceMinionsPhysicalPath": "[concat(parameter('SitesRoot'), variable('CommerceMinions')))]", | |
| "SitecoreBizFxPhysicalPath": "[concat(parameter('SitesRoot'), parameter('SitecoreBizFxName'))]", | |
| "SitecoreIdentityServerPhysicalPath": "[concat(parameter('SitesRoot'), parameter('SitecoreIdentityServerName')))]" | |
| }, | |
| "Tasks": { | |
| "RemoveCores":{ | |
| "Type": "ManageSolrCore", | |
| "Params": [ | |
| { "Action": "Unload", "Address": "[parameter('SolrUrl')]", "Arguments": { "Core": "[variable('CatalogCore')]" } }, | |
| { "Action": "Unload", "Address": "[parameter('SolrUrl')]", "Arguments": { "Core": "[variable('CustomersCore')]" } }, | |
| { "Action": "Unload", "Address": "[parameter('SolrUrl')]", "Arguments": { "Core": "[variable('OrdersCore')]" } } | |
| ] | |
| }, | |
| "RemoveCoreFiles":{ | |
| "Type": "RemoveFolder", | |
| "Params": [ | |
| { "Name": "[joinpath(variable('Solr.FullRoot'), variable('CatalogCore'))]" }, | |
| { "Name": "[joinpath(variable('Solr.FullRoot'), variable('CustomersCore'))]" }, | |
| { "Name": "[joinpath(variable('Solr.FullRoot'), variable('OrdersCore'))]" } | |
| ] | |
| }, | |
| "RemoveWebsite":{ | |
| "Type": "RemoveWebsite", | |
| "Params": [ | |
| { "Name": "[variable('CommerceOps')]" }, | |
| { "Name": "[variable('CommerceShops')]" }, | |
| { "Name": "[variable('CommerceAuthoring')]" }, | |
| { "Name": "[variable('CommerceMinions')]" }, | |
| { "Name": "[parameter('SitecoreBizFxName')]" }, | |
| { "Name": "[parameter('SitecoreIdentityServerName')]" } | |
| ] | |
| }, | |
| "RemoveAppPool":{ | |
| "Type": "RemoveAppPool", | |
| "Params": [ | |
| { "Name": "[variable('CommerceOps')]" }, | |
| { "Name": "[variable('CommerceShops')]" }, | |
| { "Name": "[variable('CommerceAuthoring')]" }, | |
| { "Name": "[variable('CommerceMinions')]" }, | |
| { "Name": "[parameter('SitecoreBizFxName')]" }, | |
| { "Name": "[parameter('SitecoreIdentityServerName')]" } | |
| ] | |
| }, | |
| "RemoveWebsiteFolder":{ | |
| "Type": "RemoveFolder", | |
| "Params": [ | |
| { "Name": "[variable('CommerceOpsPhysicalPath')]" }, | |
| { "Name": "[variable('CommerceShopsPhysicalPath')]" }, | |
| { "Name": "[variable('CommerceAuthoringPhysicalPath')]" }, | |
| { "Name": "[variable('CommerceMinionsPhysicalPath')]" }, | |
| { "Name": "[variable('SitecoreBizFxPhysicalPath')]" }, | |
| { "Name": "[variable('SitecoreIdentityServerPhysicalPath')]" } | |
| ] | |
| }, | |
| "RemoveDatabases": { | |
| "Type": "RemoveDatabase", | |
| "Params": [ | |
| { | |
| "DatabaseName": "[parameter('CommerceServicesDbName')]", | |
| "ServerName": "[parameter('SqlServer')]", | |
| "Login": "[parameter('SqlAdminUser')]", | |
| "Password": "[parameter('SqlAdminPassword')]" | |
| }, | |
| { | |
| "DatabaseName": "[parameter('CommerceServicesGlobalDbName')]", | |
| "ServerName": "[parameter('SqlServer')]", | |
| "Login": "[parameter('SqlAdminUser')]", | |
| "Password": "[parameter('SqlAdminPassword')]" | |
| } | |
| ] | |
| } | |
| }, | |
| "Modules":[ | |
| ".\\Invoke-RemoveDatabaseTask.psm1", | |
| ".\\Invoke-RemoveFolderTask.psm1", | |
| ".\\Invoke-RemoveAppPoolTask.psm1", | |
| ".\\Invoke-RemoveWebsiteTask.psm1" | |
| ] | |
| } |
This script defines tasks to do the following:
- Remove Solr cores
- Remove Solr core files
- Remove websites
- Remove app pools
- Remove website files
- Remove databases
Next, we need to add a bit to our SIFLess-EZUnistall script to run our new config file through SIF.
| #Add this to your SIFLess-EZUninstall script | |
| $commerceParams = @{ | |
| Path = "remove-commerce.json" | |
| SolrUrl = $SolrUrl | |
| SolrRoot = $SolrRoot | |
| CorePrefix = $prefix | |
| SqlServer = $SqlServer | |
| SqlAdminUser = $SqlAdminUser | |
| SqlAdminPassword = $SqlAdminPassword | |
| } | |
| Install-SitecoreConfiguration @commerceParams |
I added this as the first uninstall step right after the variable declarations, but the order isn’t really that critical.

Pingback: Yet another Sitecore Commerce 9 installation blog post | Himadri's Technical Blog