I have a project A depending on project B. Project A has some pre-build tasks that is dependent of some generated files from project B. When I build in Visual Studio, no problem. But when using MSBuild.exe, then there is problem because the build order is:
Is it the expected behaviour using MSBuild? Is there a way to tell MSBuild to do B first before A's prebuild steps?
I am using VS2010 C# and C++/CLI. I don't think if offeres additional info but here is how it is called:
Running process (C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBUILD.exe "..\..\..\dev\build\MyProj.sln" /t:Clean /p:Configuration=Release;Platform=Win32)
Short answer
Remove your build event, and add something like the following to your project (.csproj):
<Target Name="AfterResolveReferences">
<Exec Command="echo helloworld" />
</Target>
More info
You can read about customising the build process here: http://msdn.microsoft.com/en-us/library/ms366724%28v=vs.110%29.aspx
The Before Build event is fired before ResolveReferences, so if the project you reference has not already been built by the time it comes to your project's BeforeBuild event, then your BeforeBuild event will fail.
To overcome this, you should use a different entry point to customize the build process. In the above example, I use AfterResolveReferences, since this will ensure that all projects which you reference are already built.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With