2. Given the function
$$
f(x)=2 \sin \left(\omega x+\frac{\pi}{3}\right)+\cos \left(\omega x-\frac{\pi}{6}\right)(\omega>0)
$$

has the smallest positive period of $\pi$. Then $\omega=(\quad$.
(A) 4
(B) 2
(C) $\frac{1}{2}$
(D) $\frac{1}{4}$
2. B.

Notice,
$$
\begin{array}{l}
f(x)=2 \sin \left(\omega x+\frac{\pi}{3}\right)+\cos \left(\omega x+\frac{\pi}{3}-\frac{\pi}{2}\right) \\
=2 \sin \left(\omega x+\frac{\pi}{3}\right)+\sin \left(\omega x+\frac{\pi}{3}\right) \\
=3 \sin \left(\omega x+\frac{\pi}{3}\right) . \\
\text { By } T=\frac{2 \pi}{\omega} \text {, we know } \frac{2 \pi}{\omega}=\pi \Rightarrow \omega=2 .
\end{array}
$$