Not doing one’s duty with only the final benefits in mind, but as a service to society, as an offering to the divine is called Karmayoga. Not having the sense of doership (I have done this, It is because of me that this happened), without pride and egotism is Karmasanyasa. The Gita says that both are the same, two faces of the same coin.
Practicing Karmayoga first gradually purifies the mind, reducing the tendencies of pride, vanity and egotism, leading to a state of Sanyasa. This in turn further strengthens the mind to practice Karmayoga. In this way, both these approaches complement each other.