views:

62

answers:

3

We have a VS 2010 solution that includes a few class library projects, a SQL Server 2008 database project and a Wix setup project. We are trying to get to a point where the following happens in the order specified:

  1. Build the class library projects and the database project
  2. Deploy the database project to generate the deploy .sql script
  3. Build the Wix setup project.

The reason for the desired order is that the setup project requires the deployment .sql scripts as it will use these to generate/update the database on the machine that the msi is run.

It seems that there is no way within a Visual Studio solution file to create this type of build/deploy/build order. Is this correct?

Thanks

+1  A: 

How are you building it? You can change the build order in a solution from Visual Studio, granting you build it from Visual Studio. In Solution Explorer go to Build Order or so.

If you do it from command-line/MSBUILD you can build the first, then the second and the last project, easy, just call MSBUILD on each project, in the desired order. Thought there should be a finer control, I don't remember.

EDIT: It's called "Project Build Order", under the the solution node, it activates when you have more than 1 project in the solution.

Ion Todirel
We're using both Visual Studio and msbuild to build and deploy the solution file (depending on the environment). The problem is not with the project build order, it's that we need to call the deploy target for the database project before the setup project is built but after all the other projects have built.
mthornal
+1  A: 

You could change the BeforeBuild target of the Wix project (*.wixproj) to deploy the database project before the build:

  <ItemGroup>
    <DatabaseProject Include="../Database1/Database1.dbproj"/>
  </ItemGroup>

  <Target Name="BeforeBuild">
    <MSBuild Projects="@(DatabaseProject)" 
             Targets="Deploy"
             Properties="Configuration=$(Configuration);Platform=$(Platform)"/>
  </Target>
madgnome
if that works he can call that target from MSBUILD as well
Ion Todirel
That target is automatically call by MSBuild when you launch the target build.
madgnome
without touching the proj I mean
Ion Todirel
A: 

I have tried this and get an error when I tried to reload the project after editing. However ignoring the error and reloading the project again worked fine and indeed building the Wix project triggers a deploy of the database project.

Mike Hanson