Dear ladies and sirs.
My msbuild targets file contains the following section:
<ItemGroup>
<Targets Include="T1">
<Project>A\B.sln"</Project>
<DependsOnTargets>The targets T1 depends on</DependsOnTargets>
</Targets>
<Targets Include="T2">
<Project>C\D.csproj"</Project>
<DependsOnTargets>The targets T2 depends on</DependsOnTargets>
</Targets>
...
</ItemGroup>
<Target Name="T1" DependsOnTargets="The targets T1 depends on">
<MSBuild Projects="A\B.sln" Properties="Configuration=$(Configuration)" />
</Target>
<Target Name="T2" DependsOnTargets="The targets T2 depends on">
<MSBuild Projects="C\D.csproj" Properties="Configuration=$(Configuration)" />
</Target>
As you can see, A\B.sln
appears twice:
- As
Project
metadata ofT1
in theItemGroup
section. - In the
Target
statement itself passed to theMSBuild
task.
I am wondering whether I can remove the second instance and replace it with the reference to the Project
metadata of the target, which name is given to the Target
task?
Exactly the same question is asked for the (Targets.DependsOnTargets)
metadata. It is mentioned twice much like the %(Targets.Project)
metadata.
Thanks.
EDIT:
I should probably describe the constraints, which must be satisfied by the solution:
- I want to be able to build individual projects with ease. Today I can simply execute
msbuild file.proj /t:T1
to build the T1 target and I wish to keep this ability. - I wish to emphasize, that some projects depend on others, so the
DependsOnTargets
attribute is really necessary for them.