locked
Witadmin importcategories - An item with the same key has already been added RRS feed

  • Question

  • On TFS 2017 Update 2, I am attempting to export and import categories. 

    I have successfully used the Witadmin exportcategories command to export the categories to an XML file. However when I then attempt to import the file using Witadmin importcategories command I get the following error:

    An item with the same key has already been added

    This happens even if I make no changes to the XML file created by exportcategories. Before now, I have successfully done the same thing on TFS 2015 without encountering this error. Is this a bug in TFS 2017 or what might I being doing wrong?

    
    Monday, September 18, 2017 3:27 PM

Answers

  • Hi Daniel,

    Try to clean the cache folder on your client machine. The folder path is: C:\Users\username\AppData\Local\Microsoft\Team Foundation\x.0\Cache.

    Best regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, September 21, 2017 8:18 AM

All replies

  • Hi Daniel,

    I've tried with my TFS 2017.2, both witadmin exportcategories and witadmin importcategories commands work without error. You can check my commands below (I also changed nothing):

    Best regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, September 19, 2017 8:09 AM
  • Thanks for checking this out. I notice you used the VS 2015 (14.0) version of Witadmin.exe (14.95.25118.) whereas I was using VS 2017 and a later Witadmin.exe (15.117.26830.0). However I now don't think this is relevant as I found get the same error with 14.0. 

    Also I notice I get the error when I try to importcategories against the TFS 2015 instance of the collection. I was previously able to successfully import a change to the categories for one of the projects in the TFS 2015 instance so don't know what is going wrong. 

    Along the way, I also get witadmin crashes. The command below is attempting to exportcategories on the TFS 2015 project that I previously customized successfully (to add a new work item type to the Requirements category). 

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE>witadmin exportc
    ategories /collection:http://myserver:8080/tfs/DefaultCol
    lection /p:"TFS Sandbox" /f:"C:\Users\daniel.leigh\Documents\Work Item Templates
    \TFS SandboxCat.xml"

    Unhandled Exception: System.NullReferenceException: Object reference not set to
    an instance of an object.
       at Microsoft.TeamFoundation.WorkItemTracking.Client.CategoryCollection.<>c.<E
    xport>b__15_2(Category c)
       at Microsoft.TeamFoundation.WorkItemTracking.Common.Provision.CategoryHelper.
    Export[T](IEnumerable`1 categories, Func`2 getReferenceName, Func`2 getDisplayNa
    me, Func`2 getDefaultType, Func`2 getTypes)
       at Microsoft.TeamFoundation.WorkItemTracking.Client.CategoryCollection.Export
    ()
       at Microsoft.TeamFoundation.WorkItemTracking.Client.Admin.CommandLineTools.Co
    mmandExportCategories.Run(Parameters parameters)
       at Microsoft.TeamFoundation.WorkItemTracking.Client.Admin.CommandLineTools.Wi
    tAdmin.RunCommand(WitAdminCommand command, Parameters parameters)
       at Microsoft.TeamFoundation.Client.CommandLine.CommandLine.RunCommand(String[
    ] args)
       at Microsoft.TeamFoundation.Client.CommandLine.CommandLine.Run(String[]& args
    )
       at Microsoft.TeamFoundation.WorkItemTracking.Client.Admin.CommandLineTools.Wi
    tAdmin.Main(String[] args)

    Tuesday, September 19, 2017 4:21 PM
  • Hi Daniel,

    Do you try on another client machine? How's the result?

    Best regards,


    MSDN Community Support Please remember to click &amp;quot;Mark as Answer&amp;quot; the responses that resolved your issue, and to click &amp;quot;Unmark as Answer&amp;quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, September 20, 2017 8:42 AM
  • Xinxin,

    I tried on a different machine which had VS 2015 and this works - I was able to successfully export and import categories to the defaultcollection on TFS 2017 Update 2 so no longer blocked by this issue.

    I am still trying to get the original machine working as that is my primary workstation.

    Thanks for the suggestion.

    Wednesday, September 20, 2017 2:00 PM
  • Hi Daniel,

    Try to clean the cache folder on your client machine. The folder path is: C:\Users\username\AppData\Local\Microsoft\Team Foundation\x.0\Cache.

    Best regards,


    MSDN Community Support Please remember to click &amp;quot;Mark as Answer&amp;quot; the responses that resolved your issue, and to click &amp;quot;Unmark as Answer&amp;quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, September 21, 2017 8:18 AM
  • Xinxin,

    I tried this and it solved the problem! Many thanks for the suggestion, I did not know about the cache.

    Friday, September 22, 2017 8:40 AM
  • Hi Daniel,

    Please accept it as answer since it solved your issue, which will be beneficial to other community members.

    Best regards,


    MSDN Community Support Please remember to click &amp;quot;Mark as Answer&amp;quot; the responses that resolved your issue, and to click &amp;quot;Unmark as Answer&amp;quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, September 22, 2017 8:44 AM