My company has just started to use database projects as a code review tool, utilizing the compiler engine. I’m trying to automate maintaining the database project with the current database changes during the nightly build process. Using TFS 2010, I created a custom build activity that automates Visual Studio by using EnvDTE. Below are the steps performed by the build activity:
- Launch instance of Visual Studio IDE
- Open solution that contains database project
- Wait fixed amount of time for Visual Studio to verify that the model is synchronized with the source files since I couldn’t find an event that triggers when finished
- Perform schema compare (running Visual Studio Data.NewSchemaComparison command)
- Wait fixed amount of time (e.g. thread.sleep) for Visual Studio to finish schema compare since I couldn’t find an event that triggers when finished
- Perform ‘Write Updates’ action (running Visual Studio Data.SchemaCompareWriteUpdates command)
- Programmatically click ‘Yes’ button on dialog that confirms that I want to update the target
- Wait fixed amount of time for Visual Studio to perform ‘Write Updates’ action
- Programmatically click the ‘OK’ button on the dialog that confirms that target schema was updated successfully
- Wait fixed amount of time for Visual Studio reanalyze after write updates operation
- Save all changes (running Visual Studio SaveAll command)
- Programmatically click ‘Save’ button to save the schemacompare file and other changes to the database project (e.g. adding/modifying files)
Then I have another activity that will check-in the changes to TFS.
The DB project is very large with around 35000 objects; My company is not ready to replace the existing database deployment mechanism that have been developed prior to DB projects being available. Is there a better way to automate maintaining the database project? If not, then is there any way to suppress the dialogs launched from the Data.SchemaCompareWriteUpdates and SaveAll commands? Is there a way to detect when an operation completes (e.g. schema compare) using the Visual Studio commands instead of using a thread.sleep to wait a fixed period of time?
thank you,
Steve