views:

331

answers:

1

I have the following task in my MSBuild script:

 <Target Name="ZipStates">
    <Message Text="CREATING ZIP FOR %(StateSet.Name)" />

    <CreateItem Include="$(StagingArea)\v$(VersionString)\States\%(StateSet.Name)\v$(VersionString)%20%(StateSet.Abbreviation)XTend\**\*.*" >
      <Output ItemName="ZipFiles" TaskParameter="Include"/>
    </CreateItem>

    <MSBuild.Community.Tasks.Zip Files="@(ZipFiles)"
          ZipFileName="$(StagingArea)\v$(VersionString)\States\%(StateSet.Name)\v$(VersionString)%(StateSet.Abbreviation).zip" />

  </Target>

<ItemGroup>
    <StateSet Include="AK">
      <Name>Alaska</Name>
      <Abbreviation>AK</Abbreviation>
    </StateSet>
    <StateSet Include="FL">
      <Name>Florida</Name>
      <Abbreviation>FL</Abbreviation>
    </StateSet>
    <StateSet Include="LA">
      <Name>Louisiana</Name>
      <Abbreviation>LA</Abbreviation>
    </StateSet>
</ItemGroup>

The output looks like this:

ZipStates: CREATING ZIP FOR Alaska CREATING ZIP FOR Florida CREATING ZIP FOR Louisiana Creating zip file "C:\StagingArea\v5_6_0\States\Alaska\v5_6_0AK.zip".

It seems that when I do a batch in this way each command in the task is executed for every node in the item group batch and then it moves on to the next step. What I end up with is 3 zips that all contain the same files.

Anyone have an idea of how I can do this differently?

A: 

Figured it out. I needed to modify the way I was creating the file list to be unique per list. Like so:

<Target Name="ZipStates">

    <CreateItem Include="$(StagingArea)\v$(VersionString)\States\%(StateSet.Name)\v$(VersionString)%20%(StateSet.Abbreviation)XTend\**\*.*"
                Exclude="web.config">
      <Output ItemName="XtendZipFiles%(StateSet.Abbreviation)" TaskParameter="Include"/>
    </CreateItem>

    <MSBuild.Community.Tasks.Zip Files="@(XtendZipFiles%(StateSet.Abbreviation))"
          ZipFileName="$(StagingArea)\v$(VersionString)\States\%(StateSet.Name)\v$(VersionString)%(StateSet.Abbreviation)XTend.zip" />

  </Target>
NotMyself