Search code examples
c#c++visual-studiobuildpre-build-event

Visual Studio project dependancy question


I have a Visual Studio solution with projects A, B, and C. A and B are indpendant and should do some task T every time they are build. Project C is denendant to A, B and when C is built, task T should be done as well. For any case it's needed task T to be done once.

First approach: I tried to trigger task T as pre-build event on projects A and B. That doesn't work when I build C because then A and B are build in parallel and two instances of task T is run in parallel and disturb each other.

Second approach: I want to create new project D that will do pre-build event T. It will not have C++ or C# sources, just one script to perform T. Both A and B will be dependant to D. This solves the issue with paralelism but has other problems with Visual studio logic.

  1. Visual Studio will build D only when it is outdated but I need it to be run always? Is it possible?
  2. When project D is built it should not make A and B outdated.

Can you help to resolve these issues with Second approach or maybe there is better solution?


Solution

  • My colleague suggested to add this to vsxproj file:

    <ItemGroup>
       <UpToDateCheckInput Include="$(SolutionDir)\a.txt" />
    </ItemGroup>
    

    It is path to a nonexisting file a.txt. Now it is built every time