tags:

views:

44

answers:

1

I have a WIX (Windows installer XML) v3, project which contains references to other projects in my solution. I am using the copy task inside the BeforeBuild event of the WIX project to collect some of the output of the references projects for later use my heat.exe.

When I build the WIX project (not the solution) inside visual studio each of the referenced project is build before my WIX project and once they are built, the BeforeBuild event on my WIX project fires and then the WIX project itself is built. This is the beahviour I expect - I am able to access files from the bin directories of the references projects in the WIX BeforeBuild and use them as I please before WIX project executes candle.exe

The problem I am having is when I build the WIX file via msbuild I am finding that the BeforeBuild event fires straight away BEFORE any of the referenced projects. This difference in behaviour means that I cannot make use of the outputs of the referenced projects when building from the command line.

Any ideas as to why BeforeBuild is executing at a different point in time when run via msbuild on the command line to inside Visual Studio?

+1  A: 

If you are building inside VS, the solution dependencies (which can be explicit or based on the project references) are used to determine which projects need to be built and a separate build is kicked off for each of them. This is necessary since solutions can contain also projects that are not built using MSBuild and other projects have explicit dependencies set in the solution for them. The side effect is that each project is treated as a standalone build, thus ensuring the right BeforeBuild order for you..

If you are build from the command line using MSBuild, the dependency projects are resolved (and built if necessary) during the ResolveReferences target. The BeforeBuild target and PreBuild event (executed from the PreBuildEvent target) are both performed before the ResolveReferences target. Thus the dependent project BeforeBuild target ends up executing before the build for the dependency project is kicked off.

Note that from a point of view of a single project, BeforeBuild target does make sense to be executed before resolving dependencies, as the dependency resolution might itself depend on the BeforeBuild target output. For example, BeforeBuild might execute a custom script to get the latest copy of any dependency projects from the SCM.

Franci Penov
Thanks Franci.Sounds like BeforeBuild is not what I need. Is there an event I can override in my WIX project that will fire after the ResolveReferences target has built all the referenced projects?
Dav Evans