Riemann's explicit formula
$J(x)=\mathrm{Li}(x)-\sum_{\Im\varrho>0}\left(\mathrm{Li}(x^\varrho)+\mathrm{Li}(x^{1-\varrho})\right)+\int_x^\infty\frac{\mathrm{d}t}{t(t^2-1)\log t}-\log2,$
where $\varrho$ are the non-trivial zeta zeros, is an expression for $J(x)$, the prime counting function that goes up by $1/k$ for every $k$th power of a prime. For theoretical purposes, this is fine since $J(x)=\Theta(\pi(x))$ and we can recover $\pi(x)$ by Möbius inversion
$\pi(x)=\sum_{n\ge1}\frac{\mu(n)}{n}J(x^{1/n}).$
This is the reason why Riemann's suggestion
$R(x)=\sum_{n\ge1}\frac{\mu(n)}{n}\mathrm{Li}(x^{1/n})$
is a good candidate for an approximation to $\pi(x)$, and indeed performs well empirically (though it is not really superior by any general measure).
My question is: Can we plug the explicit formula for $\mathrm{Li}(x)$ into the inversion formula for $\pi(x)$ and evaluate term-wise? This would lead to
$\pi(x)=R(x)-\sum_{\varrho}R(x^\varrho)+\sum_{n\ge1}\frac{\mu(n)}{n}\int_{x^{1/n}}^\infty\frac{\mathrm{d}t}{t(t^2-1)\log t}-\log2\sum_{n\ge1}\frac{\mu(n)}{n}.$
The sum $\sum\frac{\mu(n)}{n}$ actually evaluates to $0$, so the last term would vanish. But since the sum over the zeta zeros converges only conditionally, I am not sure if swapping the order of summation in the second term would be justified and correct.
What's more, the lower bound $x^{1/n}$ for the integral converges to $1$ (for a fixed $x$), where the integrand has a pole, hence the integral would blow up to infinity (quicker than the $1/n$ can fix), and so this sum would not converge (as far as I can see and my calculations support).
Do I make a mistake in my logic, or is term-wise evaluation indeed not allowed here?
Another approach is of course to argue that the inversion sum is actually finite, since $J(x)=0$ for $x<2$ by construction, so we won't run into the convergence problem (but will neither have the convenience that the $\log2$ term vanishes). Would we just adjust the definition of $R(x)$ and the argument would go through? (I would still like to know what goes wrong in my initial train of thoughts with the infinite sum.)
I couldn't find a reference for this question, so I hope someone can help me with that.