Visual Studio setups don't let you run code during the UI part of the install, so you cannot validate the license in the UI.
Also, there is no "before the install" in Visual Studio custom actions because they all run after the files have been installed. You can write a custom action to validate the PIDKEY property (which is what it's called). If you fail it, then throw an InstallException and the entire install will roll back and uninstall, but that's a terrible unfriendly user experience.
So there is no good answer. People using VS setups can have the app validate a license key and refuse to run if it's not correct. The alternative is to figure out how to use an MSI file editor like Orca to manually add a vbscript custom action that will run when the Next button is clicked and disallow the next dialog if it's not valid, and that is extremely complicated.