I'm trying to automate a build, and I'm running into a problem building a single solution.
In this solution, project 1 references project 2, which references project 3. Project 4 also references project 3. These are VS2015 projects, and all projects have a postbuild event that copies the dll to an Assemblies folder.
When msbuild 14 starts to build the solution, it mentions in its output that project 1 builds project 2, and project 2 builds project 3, as you would expect because of the dependencies outlined above. So project 3 is built and its output copied to the Assemblies folder, then project 2, then project 1; so far so good.
Then the solution builds project 4, which also needs project 3. Unlike what I would expect, the process seems to once again build project 3, even though it was already built successfully by the same solution. Even so, it wouldn't matter (it is not very efficient, but it just takes a second), except that when the postbuild xcopy is executed again for project 3, a Sharing Violation occurs, and the xcopy fails with exit code 4. Apparently the solution or the previously built project 2 is holding a ref to the copied file or something.
Is this the usual behavior for msbuild (ie to build projects multiple times when they are referenced by multiple other projects in the same solution), or is this some setting somewhere I can affect? Note that if I open the same solution in VS2015 and do a rebuild, it works just fine, and the dll's are copied to the Assemblies folder as expected.
Thanks for any insights!