Well you need to have the solar removed before you can get your roofing work done. Then re-installed afterwards. Typically roofing and solar work is very different, so two different companies involved - just makes things a little more complicated.
Most solar companies that I've spoken to won't (or will strongly recommend against) installing solar on roofs with less than 10 years of useful life remaining.
That being said, roofs typically have a 30 to 50 year lifespan. Depending on the material, location, etc. Most quality solar panels have a warrantied life of at least 25 years. So if you're like me and had an old roof, that gets replaced first before solar gets installed.
And by the time the solar panels are EOL, the roof will be close to it as well. So they'll both get replaced again. Assuming I'm still in the same house in 30 years time.