Multiple Batches in SQL Server Migration Script
The problem is really just about error handling, as SSMS has no way to handle errors across batches when you run the script in an SSMS query window (ether normal or SQLCMD mode).  So your transaction might abort, and SSMS would run the next batch.  

If you run the script with SQLCMD you can start a transaction in the first batch, and use the -b switch.  Any error will abort the script and roll back your transaction.

EG 

use tempdb
go
begin transaction
-- be sure to run with sqlcmd -b
-- eg c:&gt; sqlcmd -b -i c:\deploy\thisscript.sql
go

--. . . any number of batches here


go

commit transaction

go


Of course you must ensure that your script does not commit or rollback the transaction, catch errors, or contain any statements that can't be run in a transaction (like adding files to a database).

You can similarly burst the batches yourself in .NET or PowerShell, start a transaction, and run each batch separately, commiting only if all batches ran without error.

Another good way to handle this whole scenario (if you can do the upgrade during an outage) is with a database snapshot. In case of a failure, restoring from a database snapshot allows a quick rollback of all the upgrade actions without the need of a transaction.