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. (This step may not be necessary, because can uncheck in the Reference Manager.)
Add back the appropriate References by browsing to the file locations.
Caution! <RevitAPIUI.dll> and <RevitUIAPI.dll> are both in the same folder. Do not get dyslexic-ly 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. Get to that dialog by going the Properties of the project. See https://youtu.be/5JMUi218rTQ?t=48
Build Solution, and if there are no problems, it should compile.