msbuildtasks
msbuildtasks copied to clipboard
ZIP Fails on Duplicate Files and Adding Folder and Contents
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.
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.
Actually I was able to fix this by moving the item group inside a task and adding KeepDuplicates="false".