2016-12-15 17 views
0

バッチファイルを実行しているmsbuildファイルがあります。msbuild itemgroup items

のMSBuildファイル:

<PropertyGroup> 
    <ItemAString>Green;Red;Blue</ItemAString> 
    <ItemBString>Uno;Due;Tre</ItemBString> 
    <ItemCString>Song;Movie;Picture</ItemCString> 
</PropertyGroup> 

<ItemGroup> 
    <ItemsA Include="$(ItemAString.Split(';'))" /> 
    <ItemsB Include="$(ItemBString.Split(';'))" /> 
    <ItemsC Include="$(ItemCString.Split(';'))" /> 
</ItemGroup> 

<Target Name = "CallBatch">      
    <!-- THIS DOES NOT WORK --> 
    <Exec Command="mybatch.bat %(ItemsA.Identity) %(ItemsB.Identity) %(ItemsC.Identity)" />    
</Target>  

バッチファイルは非常に簡単です:

echo Params = [%1] - [%2] - [%3] 

私は次の出力を取得したい:

Params = Green - Uno - Song 
Params = Red - Due - Movie 
Params = Blue - Movie - Picture 

トンを達成するための方法彼の?

+0

わからないが、あなたは最初の '$'と変数にアクセスして、 ''%とされています。私はmsbuildにはないが、それは私の目に飛びつく。 – geisterfurz007

+1

「クロスプロダクト」を検索して、回答がどこかにあるはずです。例:http://stackoverflow.com/questions/3893467/msbuild-batching-on-three-independent-variables/3893905#3893905またはhttp://stackoverflow.com/questions/37186​​867/msbuild-merge-item-groups/ 37210038#37210038または... – stijn

答えて

1

私は解決策が見つかりました:thatsのが正しい場合

<Project DefaultTarget="DoTheMagic" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0"> 
<PropertyGroup Condition=" '$(TFP)'=='' "> 
    <TFP>$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</TFP> 
    <TFP Condition=" !Exists('$(TFP)')">$(MSBuildFrameworkToolsPath)\Microsoft.Build.Tasks.v4.0.dll</TFP> 
    <TFP Condition=" !Exists('$(TFP)')">$(windir)\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll</TFP> 
</PropertyGroup> 

<UsingTask 
    TaskName="Bukake" 
    TaskFactory="CodeTaskFactory"  
    AssemblyFile="$(TFP)" > 
    <ParameterGroup> 
     <ItemsA Required="True" ParameterType="System.String"/> 
     <ItemsB Required="True" ParameterType="System.String"/> 
     <ItemsC Required="True" ParameterType="System.String"/> 
     <Result ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="True"/> 
    </ParameterGroup> 
    <Task>      
     <Code Type="Fragment" Language="cs"> 
      <![CDATA[ 
     string[] itemsA = ItemsA.Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries); 
     string[] itemsB = ItemsB.Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries); 
     string[] itemsC = ItemsC.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); 

     List<TaskItem> items = new List<TaskItem>(); 
     for (int index = 0; index < itemsA.Length; index++) 
     {        
      TaskItem item = new TaskItem(); 
      item.ItemSpec = "item"; 
      item.SetMetadata("itemA", itemsA[index]); 
      item.SetMetadata("itemB", itemsB[index]); 
      item.SetMetadata("itemC", itemsC[index]); 
      items.Add(item); 
     } 
     Result = items.ToArray();       
     ]]> 
     </Code> 
    </Task> 
</UsingTask> 

<PropertyGroup> 
    <ItemAString>Green;Red;Blue</ItemAString> 
    <ItemBString>Uno;Due;Tre</ItemBString> 
    <ItemCString>Song;Movie;Picture</ItemCString>  
</PropertyGroup> 

<Target Name = "CallBatch">  
    <Message Text="$(TFS)" /> 
    <Bukake ItemsA="$(ItemAString)" 
      ItemsB="$(ItemBString)" 
      ItemsC="$(ItemCString)"> 
     <Output TaskParameter="Result" ItemName="Dundonja" /> 
    </Bukake> 

    <ItemGroup>     
     <PreparedItems Include="@(Dundonja)"/>    
    </ItemGroup> 
    <!-- <Message Text="Dundonja: %(Dundonja.Identity) %(Dundonja.itemA) %(Dundonja.itemB) %(Dundonja.itemC)"/>   --> 
    <Exec Command="mybatch.bat Dundonja %(Dundonja.Identity) %(Dundonja.itemA) %(Dundonja.itemB) %(Dundonja.itemC)"/> 
</Target>  

関連する問題