The solution offered by @Ako in the OP's comments saved my day.
It still valid for sql server 2019 and 2022 versions
In a previous 2012 to 2019 migration I was not able to solve the Web References to a ssrs and I had to modify the export process of the reports.
Adding the references.cs class, modifying the default url and removing the web reference works perfectly.
I have renamed references.cs to ssrs.cs, updated the namespace to ssrs (this is the name of the Web Reference I usually use) and just need to import this file into my scripts for it to run.