在MSBuild的preBuildEvent和项目依赖 [英] PreBuildEvent and project dependencies in MSBuild

查看:828
本文介绍了在MSBuild的preBuildEvent和项目依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个棘手的MSBuild问题。有包含多个网站解决方案文件。每个网站需要从一个普通项目的MVC视图和其他网站内容的副本。那常见的项目副本从一个​​共享的组织空间的文件。这里有一个例子:

I'm having a tricky MSBuild issue. There is a solution file containing multiple web sites. Each web site needs a copy of MVC views and other web site content from a common project. That common project copies files from a shared organizational space. Here's an illustration:



                          Site A
  OrgShared <- Common <-  Site B
                          Site C

文件副本通过 .csproj的文件preBuildEvent执行。问题是,preBuildEvent命令运行发现之前的依赖性构建事件被解雇。因此,这里的事件序列:

File copies are performed through the PreBuildEvent of the .csproj files. The problem is that the PreBuildEvent commands run before detected dependencies' build events are fired. So here's the sequence of events:


1. Site A is build
   a. Prebuild step is executed (copy files from Common)
   b. Common is built
      i. Prebuild step is executed (copy files from OrgShared)
      ii. Build & postbuild is executed
   c. Build & postbuild are executed
2. Site B is built
   a. Prebuild step is executed (copy files from Common)
   b. Build & postbuild are executed

发生在步骤1a中的问题。因为共同的prebuild一步还没有执行,站点A不会收到间接来自OrgShared的文件。

The problem occurs at step 1a. Because the Common prebuild step has not yet executed, Site A does not receive the files that indirectly come from OrgShared.

我怎样才能有效地解决这个问题的依赖不依赖于站点A,B和; ç不必直接从OrgShared复制?

How can I effectively resolve this dependency issue without relying on sites A, B & C having to copy directly from OrgShared?

推荐答案

想通了。为什么站点A正在共同建设前的原因是因为在的.sln 文件中的排序。在该解决方案改变了订货后,我能够有共同运行preBuildEvent第一。

Figured it out. The reason why Site A was being built before Common was because of the ordering in the .sln file. After changing the ordering in the solution, I was able to have the PreBuildEvent run in Common first.

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Site A", "SiteA.csproj", "{6E7FAE47-74A6-4740-9AC5-9599E850E834}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common.csproj", "{C510B337-7459-4494-BBCB-B79FECD2AA66}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Site B", "SiteB.csproj", "{F3CAFCE9-A96D-4EE5-BE09-420E27344345}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Site C", "SiteC.csproj", "{A50C5DE2-4846-40F2-86B1-B103F413DE0F}"
EndProject

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common.csproj", "{C510B337-7459-4494-BBCB-B79FECD2AA66}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Site A", "SiteA.csproj", "{6E7FAE47-74A6-4740-9AC5-9599E850E834}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Site B", "SiteB.csproj", "{F3CAFCE9-A96D-4EE5-BE09-420E27344345}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Site C", "SiteC.csproj", "{A50C5DE2-4846-40F2-86B1-B103F413DE0F}"
EndProject

这篇关于在MSBuild的preBuildEvent和项目依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆