Moring @MarcusAndersson,
On your question I think yes, the PublishingToolsEx tool spins up when publishing a GDB, it is not tied to the ArcGIS for Desktop app , I think the PublishingToolsEx is more a legacy component.
Have you tried to spin up a new vm with a ArcGIS server that is federated and publish to that server? if this works then the corrupted part is definitely with ArcGIS server if it fails then it might be portal.
So usually when I uninstall and re-install and the error persists the corruption is either in program files or in the content.
My last resort method is as follows, backup the ArcGIS server and program files dir, uninstall and delete the program files ArcGIS C:\Program Files\ArcGIS\Server , this breaks the link to your existing system but we can recover that.
1.
Rename the arcgisserver dir e.g. arcgisserver_old "the one with the config-store"
Re-Install ArcGIS Server to the same dir.
2.
Now we want to rebuild the links to portal and any data dirs.
go into the backup and copy any folders that are missing in the new system. "only Folders".
Go trough the folders one for one .
the folders are
config-store
C:\arcgis\arcgisserver\config-store\data\{sub-dirs}\
C:\arcgis\arcgisserver\config-store\security "*special notes see below"
C:\arcgis\arcgisserver\config-store\services "*special notes wait till after fist test"
directories
do not copy over system and utilities form the backup this is internal system folders.
C:\arcgis\arcgisserver\directories\arcgiscache "*special notes wait till after fist test"
C:\arcgis\arcgisserver\directories\arcgisjobs "*special notes wait till after fist test"
C:\arcgis\arcgisserver\directories\arcgisoutput "*special notes wait till after fist test"
C:\arcgis\arcgisserver\directories\arcgissystem\arcgisinput "*special notes wait till after fist test"
config-store\data
drill down and copy folders in the above dirs
config-store\security
only copy security-config.json this is the federation and replace the existing file.
config-store\services
do not copy over system and utilities form the backup this is internal system folders.
NB Re-apply the service accounts to the ArcGIS server after the copy process .
First Test
if everything went well you will have a empty ArcGIS Server that is federated to you system with the existing federation, now do you publishing test on the empty system.
Now I have seen on upgraded systems that misplaced files can land in the content store and cause funny errors that is why we do the first test with no content. if this works then copy the content back and test again if it fails then it is a indication that something is misplaced in the content and if it works great.
Hope it Helps
Henry