This book studies generalized Donaldson-Thomas invariants $bar{DT}{}^alpha(tau)$. They are rational numbers which `count' both $tau$-stable and $tau$-semistable coherent sheaves with Chern character $alpha$ on $X$; strictly $tau$-semistable sheaves must be counted with complicated rational weights. The $bar{DT}{}^alpha(tau)$ are defined for all classes $alpha$, and are equal to $DT^alpha(tau)$ when it is defined. They are unchanged under deformations of $X$, and transform by a wall-crossing formula under change of stability condition $tau$. To prove all this, the authors study the local structure of the moduli stack $mathfrak M$ of coherent sheaves on $X$. They show that an atlas for $mathfrak M$ may be written locally as $mathrm{Crit}(f)$ for $f:Uto{mathbb C}$ holomorphic and $U$ smooth, and use this to deduce identities on the Behrend function $nu_mathfrak M$. They compute the invariants $bar{DT}{}^alpha(tau)$ in examples, and make a conjecture about their integrality properties. They also extend the theory to abelian categories $mathrm{mod}$-$mathbb{C}Qbackslash I$ of representations of a quiver $Q$ with relations $I$ coming from a superpotential $W$ on $Q$.