internal void CopyComponents(CopySettings settings, OptionMetadataCollection omc, BackgroundWorker backgroundWorker)
        {
            backgroundWorker.ReportProgress(0, "Retrieving source solution(s) components...");

            var components = RetrieveComponentsFromSolutions(settings.SourceSolutions.Select(s => s.Id).ToList(), settings.ComponentsTypes);

            var entityComponents = components.Where(c =>
                                                    c.GetAttributeValue <OptionSetValue>("componenttype").Value == 1 &&
                                                    c.GetAttributeValue <OptionSetValue>("rootcomponentbehavior").Value == 0 &&
                                                    (bool)c.GetAttributeValue <AliasedValue>("solution.ismanaged").Value == false).ToList();

            if (entityComponents.Any() && settings.CheckBestPractice)
            {
                backgroundWorker.ReportProgress(0, "Analyzing entities components behavior...");
                var emds = GetManagedEntities(entityComponents.Select(ec => ec.GetAttributeValue <Guid>("objectid"))
                                              .ToArray());

                if (emds.Any())
                {
                    throw new Exception($@"Best practices are not respected!

Managed entities should not be added in unmanaged solutions with all their assets.

Remove best practice check if you really want to copy the following entities to the target solution(s):
{string.Join(Environment.NewLine, emds.OrderBy(e => e.DisplayName?.UserLocalizedLabel?.Label).Select(e => "- " + e.DisplayName?.UserLocalizedLabel?.Label))}");
                }
            }

            foreach (var target in settings.TargetSolutions)
            {
                backgroundWorker.ReportProgress(0,
                                                $"Adding {components.Count} components to solution '{target.GetAttributeValue<string>("friendlyname")}'");

                AddSolutionComponentRequest request = new AddSolutionComponentRequest();

                foreach (var component in components)
                {
                    try
                    {
                        request = new AddSolutionComponentRequest
                        {
                            AddRequiredComponents = false,
                            ComponentId           = component.GetAttributeValue <Guid>("objectid"),
                            ComponentType         = component.GetAttributeValue <OptionSetValue>("componenttype").Value,
                            SolutionUniqueName    = target.GetAttributeValue <string>("uniquename"),
                        };

                        // If CRM 2016 or above, handle subcomponents behavior
                        if (settings.ConnectionDetail.OrganizationMajorVersion >= 8)
                        {
                            request.DoNotIncludeSubcomponents =
                                component.GetAttributeValue <OptionSetValue>("rootcomponentbehavior")?.Value == 1 ||
                                component.GetAttributeValue <OptionSetValue>("rootcomponentbehavior")?.Value == 2;
                        }

                        service.Execute(request);
                        backgroundWorker.ReportProgress(1,
                                                        $"Component {request.ComponentId} of type {omc.First(o => o.Value == request.ComponentType).Label?.UserLocalizedLabel?.Label} successfully added to solution '{request.SolutionUniqueName}'");
                    }
                    catch (Exception error)
                    {
                        backgroundWorker.ReportProgress(-1,
                                                        $"Error when adding component {request.ComponentId} of type {omc.First(o => o.Value == request.ComponentType).Label?.UserLocalizedLabel?.Label} to solution '{request.SolutionUniqueName}' : {error.Message}");
                    }
                }
            }
        }