My database project needs to include a SQL file with a command that will be run manually in another server in order to create a linked server to this one. I wish that this file would be parsed by the VSDBCMD and copied into the output folder with its variables set.

The only think I've been able to do is to have it copied into the output folder selecting for the Copy to Output Directory option Copy Always, but the file is not parsed by the VSDBCMD so its variables have no value.

Any clue?

Thank you

有帮助吗?

解决方案

Two options:

Add a deploy target to Database Project file

Configure the deployment settings for ‘My project settings’. Those settings will then be used by the build server when building the solution. When building locally, the settings used will be the ones from ‘My isolated development environment’.

1- In the database project properties

Deploy Action needs to be set to ‘Create a deployment script (.sql) and deploy the database’; this will prevent the execution of the script, it will only create it.

2- Database project file

Modify the database project file (right-click database project, select Unload, right-click again, select Edit [ProjectName].dbproj) from

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">

To

<Project DefaultTargets="Build;Deploy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">

When the Build server builds the solution containing the database project, adding the default targets will also deploy the database. This build will use the Deploy settings selected for ‘My project settings’.

Pros - Easy to set up

Cons - Developer have to manage their own Isolated development environment settings

Add to the Build Template an Invoke Process invoking vsdbcmd

Follow this procedure: http://msdn.microsoft.com/en-us/library/ff805001.aspx

Pros - Developer don’t have to manage their own Isolated development environment settings

Cons - Each time a variable is added or removed to the database project, the build template or build definition needs to be modified to reflect those changes

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top