Why is the direction of friction not being considered in this problem for calculating the work done? The solution to the problem happens to be $mg(h+kl)$ because the work done by force $F$ has to be equal to the sum of the work done by friction and gravitational force. But how is the work done by friction $kmgl$ ?
The direction ratios of friction must be in the direction of tangent evaluated at the position of the body, and since the direction ratios are changing shouldn't we integrate friction over the entire path to calculate the work done?

A body of mass $m$ was slowly hauled up the hill (see figure below) by a force $\bf{F}$ which at each point was directed along a tangent to the trajectory.  Find the work performed by this force, if the height of the hill is $h$, the length of its base is $\ell$, and the coefficient of friction is $k$.


 A: They don't give you any angles, so try some out yourself.  Let's say a portion of the slope is at 89° or very nearly vertical. The frictional force $kmg\cos \theta$ will be very nearly zero, but the progress made forward horizontally $\Delta s \sin\theta$ is also nearly zero (if $\Delta s$ is the tangential distance along the curve traveled during a small portion of the climb).  If the whole hill were at 89° degrees, it would be a very long climb to cover a horizontal distance $l$, but the frictional force the whole way would be quite small. On the other hand, if it were a gentle slope of 1°, the distance required to go $l$ forward would be shorter, but the friction would be high the whole way.
This should give you an idea of how the force and displacement vary with the angle.  Now create an expression for that and integrate as you suspected.
A: As you mentioned, the Work-KE Theorem gets you most of the way:
\begin{align}
W_{\rm net} &= \Delta K\\
W_{F_N} + W_{F_g} + W_{F_f} + W_F &= 0\\
0 + -\Delta U_g + W_{F_f} + W_F &=0 \\
&\rightarrow \quad W_F = mgh - W_{F_f}
\end{align}
And, yes, to calculate the work done by friction, you must integrate it along a path using the general definition of work (simpler expressions for work that rely on a straight path, and/or a constant force, do not apply).  The general definition of work done by a force vector along a path is:
$$
W_F = \int_{t_i}^{t_f} \vec{F} \cdot \frac{{\rm d} \vec{r}(t)}{{\rm d} t} \, {\rm d} t = \int_{t_i}^{t_f} \vec{F} \cdot \vec{v}(t) \, {\rm d} t
$$
where $\vec{r}(t)$ will be specified as a parameterized path along the hill, such that $\vec{r}(t_i)$ is the starting point and $\vec{r}(t_f)$ is the ending point. There are some immediate simplifications that can be made to this equation.  First, we know that the frictional force always points opposite to the velocity, so:
$$
W_{F_f} = \int_{t_i}^{t_f} \vec{F}_f(t) \cdot \vec{v}(t) \, {\rm d} t = \int_{t_i}^{t_f} - F_f(t) \, \left|\vec{v}(t)\right| \, {\rm d} t
$$
Second, we are told that the motion is slow. This implies that we can assume equilibrium at every moment along the path. Therefore, using Newton's Second law, we can find that $F_f = \mu_k F_N = \mu_k F_g \cos\theta$, at a point where the hill is angled at $\theta$ with respect to the horizontal (I'm using $\mu_k$ instead of $k$ because it is more conventional).  So we can write:
$$
W_{F_f} = \int_{t_i}^{t_f} - \mu_k \, m\, g \cos \theta(t) \, v(t) \, {\rm d} t 
= - \mu_k \, m \, g \, \int_{t_i}^{t_f} \cos \theta(t) \, v(t) \, {\rm d} t 
$$
Therefore, if the answer is correct, it must be that:
$$
\int_{t_i}^{t_f} \cos \theta(t) \, v(t)\, {\rm d} t = \ell 
$$
What is that integrand? Nothing but the horizontal component of the velocity vector, or,
$$
v(t) \cos \theta(t) = v_x(t)
$$
when we choose the positive $x$ axis to be horizontal and rightward. So, our integral simplifies dramatically:
$$
\int_{t_i}^{t_f} \cos \theta(t) \, v(t) \, {\rm d} t = \int_{t_i}^{t_f} v_x(t) \, {\rm d} t =\int_{t_i}^{t_f} \frac{{\rm d} x}{{\rm d} t} {\rm d} t = \int_{x_i}^{x_f} {\rm d} x
$$
And we see that the answer is indeed correct.
