VS 2013 数据库项目:基于构建配置运行的部署后脚本 [英] VS 2013 Database Project: Post-Deployment scripts to run based off of build configuration

查看:33
本文介绍了VS 2013 数据库项目:基于构建配置运行的部署后脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法/机制可用于根据构建配置在 Visual Studio 2012/2013 中基于 SSDT 的数据库项目中运行一组不同的部署后脚本?我想通过使用测试"配置进行部署来预先填充我的数据以进行测试/持续集成,但自然不想为其他环境执行此操作.不过,我似乎找不到将部署后脚本有条件地链接到构建配置的方法,这对我来说似乎很奇怪.

Is there a method/ mechanism available to run a different set of post-deployment scripts in the SSDT-based database project in Visual Studio 2012/ 2013, based off of the build configuration? I would like to pre-populate my data for testing/ continuous integration by deploying with a "Testing" configuration, but naturally don't want to do this for other environments. I can't seem to find a way to conditionally link a post-deployment script to a build configuration, though, and that seems really strange to me.

推荐答案

您也可以使用 SQLCMD 变量来做类似的事情.如果值 == "Test",则运行一组值.如果没有,请运行其他东西.我在这里写了博客:

You can use SQLCMD variables as well to do something similar. If the value == "Test", run one set of values. If not, run something else. I blogged about that here:

http://schottsql.blogspot.com/2013/05/trick-to-not-run-prepost-sql-on-publish.html

它不是在构建时完成的,脚本总是以这种方式包含在内,但如果这不是问题,它为您提供了一种轻松编写代码以轻松在各种环境中运行的方法.

It's not done on build and the scripts are always included this way, but if that's not an issue it gives you a way to easily write the code to run on various environments easily.

这篇关于VS 2013 数据库项目:基于构建配置运行的部署后脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆