0

I use msbuild in main.proj to build a project like this:

 <MSBuild Projects="outs.proj" Targets="Build">
     <Output ItemName="CustomOutputs" TaskParameter="TargetOutputs"/>
</MSBuild>

Inside outs.proj I have a custom Target, I need to add an output from this target to get .dll,.pdb,..., and .mycustomfiles

How can I send data from child project to parent project ?

Thanks in advance for your help.

Alphapage
  • 901
  • 1
  • 6
  • 29

1 Answers1

1

I'd recommend you simply Import the dependant project, however the basic scenario you described can be achieved with Target's Outputs or Returns and corresponding Output's TargetOutputs although there are few caveats as it's designed for incremental builds and not as a data transfer object.

foo.build

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="Foo1">
    <MSBuild Projects="bar.build">
      <Output TaskParameter="TargetOutputs" ItemName="Bar" />
    </MSBuild>
    <Message Text="%(Bar.Identity)" />
  </Target>

  <Import Project="bar.build" />
  <Target Name="Foo2" DependsOnTargets="Bar">
    <Message Text="%(Bar.Identity)" />
  </Target>
</Project>

bar.build

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="Bar" Outputs="@(Bar)">
    <ItemGroup>
      <Bar Include="**\*.dll" />
    </ItemGroup>
  </Target>
</Project>
Ilya Kozhevnikov
  • 10,242
  • 4
  • 40
  • 70
  • I think I can't import bar.build project because it will update foo.build properties or items values resulting in a wrong behaviour. So, I try with TargetOutputs but I build using Targets="Rebuild", bar.build is generated: unable to get Bar outputs from Foo1. – Alphapage Aug 20 '14 at 11:05
  • 1
    @Alphapage write some sample failing code, bar.build doesn't have a Rebuild target hence my example is not relevant to your use case and nobody is a mind reader. – Ilya Kozhevnikov Aug 20 '14 at 11:17
  • Just changed Rebuild;Bar in Targets and it works. I wasn't pointed to my Target. Thank you for telling me to check my target. – Alphapage Aug 20 '14 at 14:13