database Project not running Post Deployment scrip

2019-06-26 21:27发布

We have a solution with three database projects. All three produced dacpacs are deployed sequentially but for some reason, one of these dacpacs does not run the post-deployment script.

We're using sqlpackage to create a diffscript, and the diffscript does correctly include the post-deployment statements.. here's a snippet

IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT N'The transacted portion of the database update succeeded.'
COMMIT TRANSACTION
END
ELSE PRINT N'The transacted portion of the database update failed.'
GO
DROP TABLE #tmpErrors
GO
/*
Post-Deployment Script Template                         
--------------------------------------------------------------------------------------
 This file contains SQL statements that will be appended to the build script.       
 Use SQLCMD syntax to include a file in the post-deployment script.         
 Example:      :r .\myfile.sql                              
 Use SQLCMD syntax to reference a variable in the post-deployment script.       
 --------------------------------------------------------------------------------------
*/
print 'SCRIPT: dbo.MEMTYPES.data.sql'

Where: a) The Comment is in the Header postdeployment.sql script, which calls other scripts using the standard syntax : :r .\dbo.MEMTYPES.data.sql , and b) The line " print 'SCRIPT: dbo.MEMTYPES.data.sql'" is the first line of the first child script defined in the postdeployment script.

However, when run, the log of the deployment ends with the line:

The transacted portion of the database update succeeded.

Which means the dacpac schema changes were applied (and they were) but presumably no attempt was made to continue in the script to run the post deployment tasks.

Any ideas?

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-06-26 22:32

As it's a couple of months after I posted the question, and http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/ I guess I should state what the outcome was...

I couldn't find rhyme or reason for the issue other than removing the comments resolved the issue. Now that this has in effect been included in our rules to follow, we haven't come across this issue since.

查看更多
登录 后发表回答