简体   繁体   English

Visual Studio生成和部署订购

[英]Visual Studio build and deploy ordering

We have a VS 2010 solution that includes a few class library projects, a SQL Server 2008 database project and a Wix setup project. 我们有一个VS 2010解决方案,其中包括一些类库项目,一个SQL Server 2008数据库项目和一个Wix安装项目。 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 部署数据库项目以生成deploy .sql脚本
  3. Build the Wix setup project. 生成Wix设置项目。

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. 所需顺序的原因是安装项目需要部署.sql脚本,因为它将使用这些脚本在运行msi的计算机上生成/更新数据库。

It seems that there is no way within a Visual Studio solution file to create this type of build/deploy/build order. 在Visual Studio解决方案文件中似乎无法创建这种类型的构建/部署/构建顺序。 Is this correct? 这个对吗?

Thanks 谢谢

You could change the BeforeBuild target of the Wix project ( *.wixproj ) to deploy the database project before the build: 您可以更改Wix项目( *.wixproj )的BeforeBuild目标,以在构建之前部署数据库项目:

  <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. 您可以在Visual Studio的解决方案中更改构建顺序,从而可以从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. 如果从命令行/ MSBUILD进行操作,则可以轻松构建第一个,然后第二个和最后一个项目,只需按所需顺序在每个项目上调用MSBUILD。 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. 但是,忽略该错误并重新加载项目仍然可以正常工作,并且实际上构建Wix项目会触发数据库项目的部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM