No rule is inviolate
I should clarify somatic spells and possibly if you have to retrieve a material component.Wait, what? That certainly can't be right?
A combo of sage advice, warcaster feat, and object usage. Warcaster Feat specifically allows you to cast somatic spells even if your hands are full with a weapon (and shield). This is a specific rule that means you can't normally cast a somatic spell if hands are full. However, Sage Advice clarified you don't have to drop a weapon/shield to cast. You can pin, hold with another hand, etc. However, my take is that storing a weapon/shield in this way to free up a hand would cost a "free" action of sheathing a weapon (storing it to free up a hand). Since you're using your free action, you have to wait till your next turn to adjust the weapon/shield differently. This might mean a loss in AC or the ability to use the weapon in hand for attacks of opportunity.
Otherwise, if you could store, cast, and restore, the Warcaster Feat feature would be rendered useless.