Every version of a Revit API app must reference some DLLs that come with Revit’s releases.
Open the .sln of your API code. In Visual Studio’s Solution Explorer, see Properties.
One can see what Revit version an app was written for by the path of some of those references.
Remove Revit references from old Revit versions.
Add back the appropriate References by browsing to the file locations.
Caution! <RevitAPIUI.dll> and <RevitUIAPI.dll> are both in the same folders. Do not get confused!
In the Properties of each DLL, set Copy Local to False.
If there are post-build events, update the instructions.
copy "$(ProjectDir)bin\debug\myapp.dll" "C:/Users/All Users/Autodesk/Revit/Addins/2019"
Update Debug instructions if needed.
In Application, update .NET Framework if needed.
Build Solution, and if there are no problems, it should compile.