If a question is invalid, perhaps a duplicate, a list, or off topic, but not yet closed, and if it has answers, how should they be handled? Should they be upvoted if they answer the question? Should they be downvoted to discourage answering bad questions? Should they be ignored altogether?
It's not always obvious whether enough other users consider a question to be invalid to force closure, or even whether you yourself think it deserves to be closed. Who knows for sure (and who can predict with certainty) what goes on in the murky crevices of a prospective close-voter's mind, or how many other individuals there are who might vote the same way?
My suggestion is to ignore any votes to close that may or may not have been cast, and to base your decisions purely on your own assessment of the merits both of the question and the answers supplied, as well as on how strongly motivated you feel regarding your own wish to respond.
It's generally simpler and easier just to move on if the question and/or its answers don't hold any particular interest for you.
Should they be upvoted if they answer the question?
Assuming the question strikes you as worthwhile, then yes -- why shouldn't they be?
Should they be downvoted to discourage answering bad questions?
They should be downvoted anyway if they are poor answers. If you think the question itself is bad, then downvote the question (and comment on it, if necessary).
Should they be ignored altogether?
Yes, if you're not interested in either the question or the answers made to it.