本文介绍了如何将项目一个接一个地传递给另一个msbuild任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有x,y和z属性文件,还有master.properties文件

We are having x, y ,z properties files and having a master.properties file

现在,我已经在我的master.properties文件中编写了一些类似于以下的项目组,并将该项目组传递给msbuild目标,以便它像foreach一样工作.

Now , i have written in my master.properties file some itemgroup like follows and pass this itemgroup to msbuild target so that it will work like foreach.

项目组:

 <Components Include="Y:\Build\X.Properties">
      <ComponentName>X</ComponentName>
    </Components>

    <Components Include="Y:\Build\Y.Properties">
      <ComponentName>Y</ComponentName>
    </Components>

   <Components Include="Y:\Build\Z.Properties">
      <ComponentName>Z</ComponentName>
    </Components>



<Target Name="BuildAll" Inputs="@(Components)" Outputs="%(Identity).Dummy">

    <MSBuild Projects="@(Components)"

             Targets="BuildComponent" />

  </Target>

现在我想拥有一个txt文件,其中将以这样的方式给出组件名称

Now I want to have a txt file where component names will be given like this

X是

它应该仅单独构建X和Y.

it should build only X and Y alone.

我尝试使用ReadLinesFromFile,但是我无法一一传递.

I was trying with ReadLinesFromFile , but i am not able to pass one by one component.

例如:

 <ReadLinesFromFile File="Allcomponent.txt">
      <Output TaskParameter="Lines" ItemName="AllComponent" />
  </ReadLinesFromFile>

然后,我要一一传递项目组中的组件以调用Msbuild任务.

Then I want to pass component in the itemgroup one by one to call Msbuild tasks.

如何解决这个问题?

推荐答案

最后,我找到了解决方案.解决方案如下

Finally i found the solution. The solution is like below

我应该使用组件名称创建属性.

I should create property with Component names.

<X>Y:\Build\X.Properties</X>
<Y>Y:\Build\Y.Properties</Y>
<Z>Y:\Build\Z.Properties</Z>

在Msbuild任务中,我应该遵循以下

And in Msbuild task , I should follow as below

<Target Name="BuildAll" >

    <ReadLinesFromFile  File="$(AllComponents)">
      <Output TaskParameter="Lines" ItemName="AllComponents"/>
    </ReadLinesFromFile>

    <MSBuild Projects="$(%(AllComponents.Identity))"

             Targets="BuildComponent" />

</Target>

现在它将构建我通过文本文件传递的组件.

Now it will build the component which i pass through the text file.

这篇关于如何将项目一个接一个地传递给另一个msbuild任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 14:33