开发者

Visual Studio build and deploy ordering

We have a VS 2010 solution that includes a few class library projects, a SQL Server 2008 databa开发者_运维知识库se 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


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>


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜