Azure DevOps, Scrum, & .NET Software Leadership and Consulting Services

Free course! Predicting the Future, Estimating, and Running Your Projects with Flow Metrics

Making pre- and post-deployment scripts run in a VSTS DBPro build.


I’m going to be doing the keynote at the launch of Visual Studio Team Editor for Database Professionals (aka VSTS DBPro, “data dude”) tomorrow.  I wanted to play around with creating default values in lookup tables as part of my demo.  DBPro gives you this functionality through pre-deployment and post-deployment scripts.  You write your own script and that data gets inserted into the database.

Well, I kinda had some trouble getting that to work.  I created the post-deploy script and ran the build but the values weren’t being inserted.  How do I make DBPro actually run my custom post-deployment scripts?

Not surprisingly, I missed something in the process.  I created the script but I didn’t actually tell VSTS to run it.  There are two files that govern these pre- and post- scripts: Script.PreDeployment.sql and Script.PostDeployment.sql.  When you create a new script, you need to register it for execution inside of one of these config files.

Example: I’ve got a bunch of Restaurant Type lookup values that need to get set so I created a script called CreateRestaurantTypes.sql.  In order to make it run, I needed to edit Script.PostDeployment.sql and add the following line:

:r .CreateRestaurantTypes.sql

That fixed it.  (duh.)

-Ben

 

— Looking for consulting or training for Visual Studio Team System or Team Foundation Server?  Contact us via http://www.benday.com.

SUBSCRIBE TO THE BLOG

,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.