Here's how you would account for risk aversion.
First of all, I think this problem is usually set up using weights as the variables (see here http://www.math.ku.dk/~rolf/CT_FinOpt.pdf, page 141). If you want to use dollar weights, you will have to transform the result.
The optimization problem is:
$$ \max_w \quad w'\mu −\frac{\gamma}{2} w'\Sigma w$$
Weights add up to 1:
$$ w'e = 1 $$
Where you have $N$ assets, $w$ and $\mu$ are $N\times1$ vectors, and $\Sigma$ is an $N\times N$ matrix. $e$ is an $N\times1$ vector of ones.
The Lagrangian for the problem is:
$$ \max_w \quad w'\mu −\frac{\gamma}{2} w'\Sigma w + \lambda (w'e - 1)$$
To optimize, we take the gradient of the objective function, and set each element equal to zero. So we will have an $N\times 1$ vector equation:
$$0 = \mu - \gamma \Sigma w + \lambda e$$
This can be solved for $w$:
$$w = \left(\gamma \Sigma\right)^{-1} \left(\mu + \lambda e\right)$$
Plugging this back into the constraint, we get:
$$ \left(\left(\gamma \Sigma\right)^{-1} \left(\mu + \lambda e\right)\right)'e = 1$$
The transpose reverses the order of the terms, and has no effect on the symmetric $\Sigma^{-1}$ matrix:
$$ \left(\left(\mu' + \lambda e'\right)\frac{\Sigma^{-1}}{\gamma} \right)e = 1$$
This can be simplified to:
$$ \mu' \Sigma^{-1} e + \lambda e' \Sigma^{-1} e = \gamma$$
Solving for $\lambda$, we get
$$ \lambda = \frac{\gamma - \mu' \Sigma^{-1} e}{e'\Sigma^{-1} e} $$
So the overall formula for the weights is:
$$w = \left(\gamma\Sigma\right)^{-1} \left(\mu + \frac{\gamma - \mu' \Sigma^{-1} e}{e'\Sigma^{-1} e} e\right)$$