lenikur
lenikur

Reputation: 31

Why MSBuild task does not build a project dependencies?

I have Visual Studio 2013 solution that has a lot of C# projects. There is a requirement says that project B must be built after a project (A) build finish.

Project A has no dependency on project B. Project B has dependency on projects A, C and others. All dependencies are defined as project references.

I added a following target to project A:

<Target Name="MyAfterBuildStep" AfterTargets="AfterBuild">
  <MSBuild Projects="$(Bproject)" Properties="Configuration=$(ConfigurationName);Platform=$(PlatformName);SolutionDir=$(SolutionDir);BuildProjectReferences=true"/>
</Target>

It starts but it does not build dependencies of $(Bproject).

Could someone help me to understand why dependencies are not built and what should I do to build them?

Upvotes: 1

Views: 1575

Answers (1)

KMoraz
KMoraz

Reputation: 14164

If both projects on the same solution, build Bproject as a target with $(SolutionPath), e.g.:

<MSBuild Projects="$(SolutionPath)" Targets="Tests\Bproject" Properties="Configuration=$(ConfigurationName);Platform=$(PlatformName);SolutionDir=$(SolutionDir);BuildProjectReferences=true"/>

The target name should reflect the name of the project including the solution folders.

Upvotes: 1

Related Questions