The Rema in [Even Ha'Ezer 1:6](http://beta.hebrewbooks.org/tursa.aspx?a=eh_x7487) writes that one fulfills the mitzvah of p'ru u'revu with a child who is a mamzer, which by definition is out of wedlock:

>היה הבן ממזר... קים המצוה

>If the child is a _mamzer_, he fulfills the mitzvah.

Minchas Chinuch Mitzvah #1 explains that it is not a _mitzvah haba b'aveira_ using the idea of the Shaar HaMelech Hilchos Lulav 8:5, that a _mitzvah haba b'aveira_ only undermines the fulfillment of a _mitzvah_ when the _aveira_ is done at the time of the fulfillment of the _mitzvah_, which is not the case by _p'ru u'revu_ which is only fulfilled when the child is born. Minchas Chinuch supports this assertion with the fact that one is not considered to have fulfilled his obligation if he has not borne children, or the children did not survive, no matter how many times he has cohabited with a woman.