In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
1- The majority of scholars state that selling in the mosque is categorically disliked with a light disapproval.
2- Other scholars say that it is forbidden if it is done in such a way wherein the seller sets up shop in the mosque, disturbing the worshippers, taking up needed space in the mosque, doing it on a customary basis or haggling loudly in the mosque. If those issues are not present, they consider it slightly disliked or permitted.
In responding to your question about auctioning off items donated to the mosque, Dr. Waleed Al-Maneese, a Senior Member of the Permanent Fatwa Committee of the Assembly of Muslim Jurists in America (AMJA), states:
The Default Ruling Concerning Auctions
The majority of the jurists say that auctions are permissible, basing their view on a hadith on the authority of Anas ibn Malik stating that Prophet Muhammad (peace be upon him) auctioned off some items on behalf of a poor person. (Abu Dawud, At-Tirmidhi and others.)
Umar ibn Al-Khattab auctioned off a camel from the Zakah camels. (Ibn Abi Shaibah)
The Ruling Concerning Selling in the Mosque
There are hadiths that prohibit selling in the mosque. The most authentic of them are: Abdullah ibn Amr stated the Prophet prohibited buying and selling in the mosque. (Al-Nasai, Abu Dawud and others)
Abu Hurairah narrated that the Messenger of Allah (peace and blessings of Allah be upon him) said, “If you see someone buying or selling in the mosque, say to him, ‘May Allah not give you any profit in your deal.’” (Ibn Khuzaimah, Ibn Hibban and others)
Al-Shawkani states that the majority of the scholars understand this prohibition to imply disapproval. He quotes Imam Al-Iraqi stating that the scholars agree that if such a sale takes place in the mosque, it cannot be nullified.
Al-Shaukaani notes that there is no sound evidence to understand the hadith’s prohibition above to mean simply disapproval and not forbiddance. He also notes that there is no contradiction between saying the sale is forbidden and it cannot be nullified.
In the Hanafi school, buying and selling in the mosque is “disliked bordering prohibited” in some cases and simply disliked in other cases. In the Maliki school, buying and selling in the mosque is not permitted although they permit haggling in the mosque over the price of an item already seen. The Shafi`is view such an act to be disliked, unless it is done in a manner that bothers those who are praying, in which case it becomes forbidden. The majority of the Hanbalis consider buying and selling in the mosque to be forbidden while others consider it disliked. The Zhahiris consider it disliked.
Note that the jurists take into consideration the legal cause for the prohibition of selling in the mosque.
Some, being the majority, state that selling in the mosque is categorically disliked with a light disapproval.
Others say that it is forbidden if it is done in such a way wherein the seller sets up shop in the mosque, disturbing the worshippers, taking up needed space in the mosque, doing it on a customary basis or haggling loudly in the mosque. If those issues are not present, they consider it slightly disliked or permitted.
Almighty Allah knows best.