msbuildtasks icon indicating copy to clipboard operation
msbuildtasks copied to clipboard

ZIP Fails on Duplicate Files and Adding Folder and Contents

Open CoreyCaldwell opened this issue 13 years ago • 2 comments

In our MSBuild task, the items we want to zip up and push are generated by:

<CreateItem Include="@(FilesToChange);
                        $(WebConfig);
                        $(CheckoutPath)\$(WebApplicationFolder)\bin\**\*.*;
                        $(CheckoutPath)\$(WebApplicationFolder)\UserControls\**\*.ascx;
                        $(CheckoutPath)\$(WebApplicationFolder)\Styles\less\**\*.*"
            Exclude="$(CheckoutPath)\$(WebApplicationFolder)\**\*.cs;">
    <Output TaskParameter="Include" ItemName="FilesToPush" />
</CreateItem>

If there is a real change in the web.config, this results in 2 web.config entries and causes the zip task to fail with "An item with the same key has already been added." We also get this error when we add a new directory with files as the directory is added as well as the child files.

CoreyCaldwell avatar Jun 27 '12 16:06 CoreyCaldwell

I am experiencing the same error after upgrading to the latest from an old version but have not confirmed whether the cause is as described here.

Kazark avatar May 28 '15 13:05 Kazark

Actually I was able to fix this by moving the item group inside a task and adding KeepDuplicates="false".

Kazark avatar May 28 '15 14:05 Kazark