Was Xamarin's action and the way the action was done ethical or not?
Well, let's ask an expert - The Open Source Initiative's listing of the MIT License itself, with the license quoted in its entirety:
The MIT License (MIT)
Copyright (c)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
If anyone - individual or company - releases software/source code with an MIT license, it means that anyone else - individual or company can "deal in the Software without restriction". So long as the copyright notice stays intact, they are pretty much able to do as they please.
This is one of those cases when ethics and legality are pretty much exactly the same. If a person or group didn't understand the license or its implications then they failed to do their due diligence. The Open Source Initiative provides lots of other nice resources to help us understand licenses like the MIT variant. Let's look at a few clauses of their Open Source Definition:
1) Free Redistribution - The license shall not restrict any party from selling or giving away the software as a component of an aggregate
software distribution containing programs from several different
sources. The license shall not require a royalty or other fee for such
sale.
3) Derived Works - The license must allow modifications and derived works, and must allow them to be distributed under the same terms as
the license of the original software.
5) No Discrimination Against Persons or Groups - The license must not discriminate against any person or group of persons.
6) No Discrimination Against Fields of Endeavor - The license must not restrict anyone from making use of the program in a specific field of
endeavor. For example, it may not restrict the program from being used
in a business, or from being used for genetic research.
To my reading this seems all abundantly clear: releasing something as open source, especially with the MIT license, allows someone to freely take the software, change it, package it, and sell it to pretty much whoever they like, so long as they don't remove your copyright notice and claim it to be their own sole work.
As the author you are explicitly giving up the right to be picky and choosy. You don't get to decide who or what can benefit from your software or make use of it, and you don't get to decide why they are using it. You explicitly give up that right.
The idea is that you are contributing to the greater good by explicitly renouncing any legal rights you have to control and restrict use and change of what you have made. If Microsoft wants to fork your FluffBall project and sell it for $2k per seat as WindowsSpongeCake, they can. Wasn't letting people do whatever they want the whole point of your project in the first place?
Is it possible to avoid such a situation if you are a single developer or a small unfunded group of developers?
Kind of! First, use a license that's appropriate to you and your organization's goals and desires. If you don't want anyone to use it in a way you don't approve of, you probably shouldn't be releasing it as Open Source - and frankly you maybe shouldn't be releasing it at all! If you don't want anyone to use a derivative work (like a fork) on a commercial project you should probably go for a copyleft version of the GPL. If you want a noncommercial license you should probably get a copyright/license lawyer to advise, because this is often not considered "open source" software at all and there isn't any major pre-written license to support this case.
The issue with the Xamarin and Coco kerfuffle is not a matter of ethics or legality - it's about an internet fight between a few people who have a beef with each other. We're all human, it happens. It seems to be the result of being unable to collaborate/cooperate, likely due to a personality conflict or incompatible visions for how the project should be handled.
So the other way of defense is being open to collaboration and change, but understand that if it doesn't work out and visions diverge...well, that's the reason for the option to fork and have your own separate project.
It's very human and understandable for feelings of ownership and popularity to make software projects very, very complicated. But the goal of open source is to try to transcend that and allow the best software to be available freely to all.
Bottom-line, be clear about your goals when you are deciding a license, and understand its implications for your future control and direction of the project. If you just want to donate to the greater good, open source is the way to go. If you want to control your project more tightly and have ownership and at least a legal case if someone tries to market your project or absorb it into their own (in part or entirely), you'll need a different license and will probably need to sort it out with a lawyer.