Casting a spell with a long casting time requires the caster to use their action each turn casting the spell:
you must spend your action each turn casting the spell
However, what would happen if while casting a long casting time spell (out of combat), a caster is suddenly attacked and is surprised?
Being surprised, the caster won't be able to use his action during his turn to continue casting the spell so is the spell forcefully lost? If it is lost, is the caster still considered to be concentrating on it up until his turn comes up?
This matters in particular for Pock, a level 12 War Magic Wizard who is ritually casting a tiny hut spell when his party gets ambushed. He would like to maintain the spell being cast as long as possible (or at least until he can actually take an action) to benefit from Durable Magic.
Best Answer
Rules as Written, the Spellcaster would lose the spell
This is relatively straightforward. The rules for spellcasting state unambiguously that a caster casting a spell with a long casting time must use their action each turn to cast it:
Meanwhile, the rules for the Surprised condition are also quite clear:
So these two factors in conjunction show that the spellcaster, being unable to use their Action on their turn, must lose all their progress on the spell they're casting.
"But that seems like a really dumb rule!"
Yes. It does, which is why I don't rule this way in my games.
The Surprised condition in 5th Edition is an abstraction not of a character literally having an emotional paroxysm, but instead of the latency the character experiences in reacting to another character's actions. It doesn't make a lot of narrative sense for a surprise attack—especially if it doesn't hit the spellcaster in question, or wasn't even targeting them—to interrupt their spellcasting.
Certainly, a successful hit against a spellcaster would trigger Concentration checks, which have a chance in their own right of disrupting the spell (since casting a spell with a long cast time requires the maintaining of Concentration), and attacks made against a surprised character are more likely than not to be especially dangerous (Unseen Attackers, First Round bonuses, etc.) so the mechanics are likely to cause a caster's disruption even if they ignore this particular rule. But from my perspective, it doesn't make much sense for the spellcaster to automatically lose the spell.
So in a game that is strictly rules-as-written, or in an Adventurer's League setting, the spellcaster would have to lose the spell. But at my table, this rule would be ignored.