本文介绍了添加输出或将数据从子项目传输到父项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我在main.proj中使用msbuild来构建这样的项目:

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

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

在outs.proj内部,我有一个自定义目标,我需要从该目标添加输出以获取.dll,.pdb,...和.mycustomfiles

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 ?

预先感谢您的帮助.

推荐答案

我建议您简单地Import依赖项目,但是可以使用TargetOutputsReturns和相应的OutputTargetOutputs尽管有一些警告,因为它是为增量构建而不是作为数据传输对象而设计的.

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

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

bar.build

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="Bar" Outputs="@(Bar)">
    <ItemGroup>
      <Bar Include="**\*.dll" />
    </ItemGroup>
  </Target>
</Project>

这篇关于添加输出或将数据从子项目传输到父项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:15