1

我有两个项目组

<ItemGroup>
    <Device Include="device1">    
     <Cdname>code1</Cdname>
    </Device>
     <Device Include="device2">    
      <Cdname>code2</Cdname>
    </Device>
    <Device Include="device3">    
      <Cdname>code3</Cdname>
    </Device>
    <Device Include="device4">    
      <Cdname>code4</Cdname>
    </Device>
    <Device Include="device4">    
      <Cdname>code4</Cdname>
    </Device>
    <Device Include="device5">    
      <Cdname>code5</Cdname>
    </Device>
    <Device Include="device6">    
      <Cdname>code6</Cdname>
    </Device>
    <Device Include="device7">    
      <Cdname>code7</Cdname>
    </Device>
    <Device Include="device8">    
      <Cdname>code8</Cdname>
    </Device>
    <Device Include="device9">    
      <Cdname>code9</Cdname>
    </Device>
    <Device Include="device10">    
      <Cdname>code10</Cdname>

取决于

    <Device Include="device1000">    
      <Cdname>code1000</Cdname>
    </Device>
</ItemGroup>

<ItemGroup>
  <Gpdname Include="d:\gpd\gpd1.GPD">
       <GPDFile>gpd1.GPD</GPDFile>
   </Gpdname>
   <Gpdname Include="d:\gpd\gpd2.GPD">
        <GPDFile>gpd2.GPD</GPDFile>
   </Gpdname>
</ItemGroup>

我的目标如下

 <Target Name="CopyGPD" Inputs="@(Gpdname)" Outputs="d:\%(Device.Cdname)\drvs\gpd\%(GPDFile)">

复制过程完成后,gpd1.GPD 和 gpd2.GPD 从 d:\gpd 复制到 d:\drvs\gpd\gpd1.GPD 和 d:\drvs\gpd\gpd2.GPD

但我想把它复制到

d:\code1\drvs\gpd\gpd1.GPD

d:\code1\drvs\gpd\gpd2.GPD

d:\code2\drvs\gpd\gpd1.GPD

d:\code2\drvs\gpd\gpd2.GPD

d:\code3\drvs\gpd\gpd1.GPD

d:\code3\drvs\gpd\gpd2.GPD

d:\code4\drvs\gpd\gpd1.GPD

d:\code4\drvs\gpd\gpd2.GPD

d:\code5\drvs\gpd\gpd1.GPD

d:\code5\drvs\gpd\gpd2.GPD

取决于 - - - - - - - - -

d:\code1000\drvs\gpd\gpd1.GPD

d:\code1000\drvs\gpd\gpd2.GPD

请帮忙

4

1 回答 1

0

如果您不坚持确切的顺序(gdp1.GDP然后gdp2.GDP是每个顺序Cdname),这将起到作用(感谢Phil Cupp:我不想忘记的 MSBuild 技巧):

<Target Name="Cartesian_Device_GDP">
    <ItemGroup>
        <C Include="@(Device)">
            <A>%(Device.Cdname)</A>
        </C>
    </ItemGroup>

    <ItemGroup>
        <D Include="@(C)">
            <B>%(Gpdname.GPDFile)</B>
        </D>
    </ItemGroup>

    <CreateItem Include="@(D)">
        <Output TaskParameter="Include" ItemName="CombinedDeviceGDP" />
    </CreateItem>
</Target>

<Target Name="Msg" DependsOnTargets="Cartesian_Device_GDP">
    <Message Text="D:\%(CombinedDeviceGDP.A)\drvs\gpd\%(CombinedDeviceGDP.B)" />
</Target>
于 2012-06-29T11:17:51.603 回答