Fixed installation error with Sitecore.Xdb.Collection.Database.SqlShardingDeploymentTool.exe returned a non-zero exit code

For a POC on Sitecore- I was installing Sitecore 10 using Sitecore Install Assistant (SIA) few days back and in the process I ran into an issue where it breaks at step #52 (creating shards).

Everything was fine as per the Sitecore 10 Installation guide, all the modules and utilities were installed like – Microsoft.SqlServer.TransactSql.ScriptDom, Microsoft.SqlServer.Types.dll and Microsoft.SqlServer.Dac.dll.

I used the same setup to install Sitecore 9 (9.3 to be precise) before and it worked like a charm.

Also, I checked and found that path to “Data-Tier application framework”, “SQL ScriptDOM” and “CLRTypes” were also added to registry as mentioned in some of the articles.

Observed the following error for ref.

[ XConnectXP0_SetServicesCertStorePe... : FilePermissions ---------------------]
[XConnectXP0_SetServicesCertStorePermissions]:[Allow] NT AUTHORITY\LocalService
[XConnectXP0_SetServicesCertStorePermissions]:[Path] C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\7c7bac47142b92c79c036c95fd8760ac_d0ab05c7-b351-4434-adff-53512d7e05d0
[XConnectXP0_SetServicesCertStorePermissions]:[Rights] Read
[XConnectXP0_SetServicesCertStorePermissions]:[Inherit] None
[XConnectXP0_SetServicesCertStorePermissions]:[Propagate] None

[------------- XConnectXP0_CleanShards : Command -----------------------------]
[ShardingTool - Clean]:[Path] D:\Deploy\SC9\sitecore10.xconnect.dev.local\App_Data\collectiondeployment\Sitecore.Xdb.Collection.Database.SqlShardingDeploymentTool.exe

[------------ XConnectXP0_CreateShards : Command -----------------------------]
[ShardingTool - Create]:[Path] D:\Deploy\SC9\sitecore10.xconnect.dev.local\App_Data\collectiondeployment\Sitecore.Xdb.Collection.Database.SqlShardingDeploymentTool.exe
Command D:\Deploy\SC9\sitecore10.xconnect.dev.local\App_Data\collectiondeployment\Sitecore.Xdb.Collection.Database.SqlShardingDeploymentTool.exe returned a non-zero exit code - (2)
[TIME] 00:04:26
Command D:\Deploy\SC9\sitecore10.xconnect.dev.local\App_Data\collectiondeployment\Sitecore.Xdb.Collection.Database.SqlShardingDeploymentTool.exe returned a non-zero exit code - (2)

I had two versions of SQL- 2017 and 2019, but 2019 was installed later, i tried to run the script before with 2017 also but it didn’t worked.

Solution- As next step- I removed the reference of “Microsoft.SqlServer.TransactSql.ScriptDom” from GAC using gacutil tool, ran it again and it worked fine, i think some how it was not able to pick which version of ScriptDom to take and part of this process it removed version 14.0.0.0 and 15.0.0.0 of ScriptDom from GAC .

"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\gacutil" -u Microsoft.SqlServer.TransactSql.ScriptDom

This was annoying but finally was able to get through this, thought of sharing this here so it helps others in future.

Hope it helps.

Happy learning 🙂