An Item with the same key has already been added. Uipath.System.Runtime.Windows

Hi Team, I downloaded a package from Orchestrator. I wanted to update this package, its already published and working fine. But now when I am publishing this after slight code modification it gives an error as
An Item with the same key has already been added. Key UiPath.System.Runtime.windows

23.4.4+Branch.support-v23.4.Sha.945d5c2edbcdd77cdd9ba7fe5accc15c57daf757

An item with the same key has already been added. Key: UiPath.System.Runtime.Windows

Error: System.ArgumentException: An item with the same key has already been added. Key: UiPath.System.Runtime.Windows
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](List1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector)
at UiPath.Project.WorkflowProjectRepository.OpenProjectFromText(IWorkflowProject project, IEnumerable`1 runtimePackages, Boolean ignoreOutputType)
at UiPath.Studio.ProjectPackager.Publish.Services.ProcessPublishProcessor.CloneWorkflowProject(IWorkflowProjectModel projectModel)
at UiPath.Studio.ProjectPackager.Publish.Services.PublishProcessor.SetupAsync(IWorkflowProjectModel projectModel, ProjectPublishSettings settings)
at UiPath.Studio.ProjectPackager.Publish.Services.ProjectPublishProcessor.SetupAsync(IWorkflowProjectModel projectModel, ProjectPublishSettings settings)
at UiPath.Studio.ProjectPackager.Publish.Services.ProcessPublishProcessor.SetupAsync(IWorkflowProjectModel projectModel, ProjectPublishSettings settings)
at UiPath.Studio.ProjectPackager.Publish.Services.PublishService.PublishAsync(IWorkflowProjectModel projectModel, IPublishSettings settings), HResult -2147024809

The error message “An Item with the same key has already been added. Key: UiPath.System.Runtime.Windows” indicates a conflict during the publishing process of your UiPath package. This likely stems from having duplicate references to the “UiPath.System.Runtime.Windows” activity package with different versions.

Here’s how to troubleshoot and fix this issue:

1. Identify Conflicting Dependencies:

  • Open your UiPath project file (usually a *.xaml file) in a text editor like Notepad++.
  • Search for “UiPath.System.Runtime.Windows”. This should highlight the lines referencing the package and its version.
  • Look for any instances where the package is included with multiple versions.

2. Resolve Dependency Conflicts:

There are two main approaches to address the conflict:

  • Update Dependencies: If one of the references is an older version, update it to match the newer version used elsewhere in your project. You can achieve this through the UiPath Package Manager within Studio.
  • Remove Redundant Reference: If the reference seems unnecessary, remove it from your project. Make sure this doesn’t break any functionalities that rely on that specific version.

3. Clean and Rebuild (Optional):

  • After resolving the dependency conflict, consider cleaning and rebuilding your project. This can help ensure UiPath Studio uses the updated or removed references correctly during publishing.

Additional Tips:

  • Utilize the Package Manager: The UiPath Studio package manager provides a centralized view of all dependencies used in your project. Use it to check for version conflicts and update packages as needed.
  • Refer to Documentation: For detailed information on managing dependencies and publishing packages in UiPath, refer to the official documentation: https://docs.uipath.com/

By following these steps, you should be able to resolve the dependency conflict and successfully publish your updated UiPath package.