Nitrile-containing azoloazines with a bridged nitrogen atom are of interest as molecules with potential antiviral and antidiabetic activity. To date, a few corresponding 7-aminoazolo[1,5-a]pyrimidine-6-carbonitriles has been described in the literature and there is no universal method for their synthesis, which limits the possibility to optimize structure for preparing derivatives with prescribed biological activity. In the present work, we have studied different conditions for cyclocondensation of aminoazoles and (ethoxymethylidene)malononotrile; we have shown that optimal method for synthesis of 7-aminoazolo[1,5-a]pyrimidine-6-carbonitriles is the heating of initial components in pyridine. This method provides a library of different nitrileazolopyrimidines containing both electron-donating and electron-withdrawing substituents in the azole fragment.