Normally, this is not allowed in Mono and throws an exception. Unity apparently suppresses thisit and tells you nothing. Here's what actually happens in your code:
Awake()
{
Transform obj = InstantiateTarget();
//While there are no children attached to this transform;
while (transform.childCount > 0) /*Not an infinite loop
because on each step you're removing
a child from this transform
(read on for the explanation).*/
{
//Try to attach each child to obj
foreach (Transform t in transform)
{
t.parent = obj; /*The first "t" gets attached, but you're also
altering the collection (this.transform loses track of t).
The foreach loop stops completely!
Since you're executing the foreach loop for
as long as this.transfom has children, you
essentially remove one child transform at a time on
each 'while' pass.*/
}
}
Destroy(gameObject);
}