Answer
$$ y=-x\cos x- x$$
Work Step by Step
Given $$x y^{\prime}=y+x^{2} \sin x, \quad y(\pi)=0$$
Rewriting the equation as
$$ y^{\prime}-\frac{1}{x} y=x\sin x $$
Since the equation is linear and $p(x)= \frac{-1}{x} $ and $q(x)=x\sin x $, then
\begin{align*}
\mu &=e^{\int p(x)}dx\\
&= e^{\int \frac{-1}{x} dx}\\
&=e^{-\ln x}\\
&=x^{-1}
\end{align*}
Hence the general solution given by
\begin{align*}
\mu(x)y&=\int \mu(x)q(x)dx\\
x^{-1} y&= \int x^{-1} x\sin x dx\ \ \\
&=\int \sin xdx\\
&= -\cos x+C
\end{align*}
Then
$$ y=-x\cos x+Cx$$
Since $y(\pi )=0 $, then $C=-1$, hence
$$ y=-x\cos x- x$$