// Generate the combines dependencies from the projectjson jObject and from AdditionalDependencies
        private JObject GenerateDependencies(JObject projectJsonRoot, ITaskItem[] externalPackageVersions, string framework = null)
        {
            var originalDependenciesList = new List<JToken>();
            var returnDependenciesList = new List<JToken>();
            var frameworkDependencies = GetFrameworkDependenciesSection(projectJsonRoot, framework);
            if (frameworkDependencies != null)
            {
                originalDependenciesList = frameworkDependencies.Children().ToList();

                // Update versions in dependencies
                foreach (JProperty property in originalDependenciesList.Select(od => od))
                {
                    // Validate that the package matches the identity regex for packages we want to update.
                    Match updateDependency = _identityRegex.Match(property.Name);

                    // if the package is in the external packages list then we'll
                    // need to replace the version with the version from the list
                    string externalVersion = null;
                    if (externalPackageVersions != null)
                        externalVersion = externalPackageVersions.FirstOrDefault(epv => epv.ItemSpec.Equals(property.Name, StringComparison.OrdinalIgnoreCase))?.GetMetadata("Version");

                    if (updateDependency.Success || externalVersion != null)
                    {
                        NuGetVersion nuGetVersion;
                        if (externalVersion == null)
                        {
                            if (NuGetVersion.TryParse(property.Value.ToString(), out nuGetVersion))
                            {
                                Match m = _versionStructureRegex.Match(nuGetVersion.ToString());

                                if (m.Success)
                                {
                                    NuGetVersion dependencyVersion = nuGetVersion;
                                    nuGetVersion = NuGetVersion.Parse(string.Join(".", dependencyVersion.Major, dependencyVersion.Minor, dependencyVersion.Patch) + "-" + PackageBuildNumberOverride);
                                }
                            }
                        }
                        else
                        {
                            nuGetVersion = NuGetVersion.Parse(externalVersion);
                        }

                        // Only add the original dependency if it wasn't passed as an AdditionalDependency, ie. AdditionalDependencies may override dependencies in project.json
                        if (AdditionalDependencies.FirstOrDefault(d => d.GetMetadata("Name").Equals(property.Name, StringComparison.OrdinalIgnoreCase)) == null)
                        {
                            JProperty addProperty;
                            if (nuGetVersion != null)
                            {
                                addProperty = new JProperty(property.Name, nuGetVersion.ToString());
                            }
                            else
                            {
                                addProperty = property;
                            }
                            returnDependenciesList.Add(addProperty);
                        }
                    }
                    else
                    {
                        returnDependenciesList.Add(property);
                    }
                }
            }

            foreach (var dependency in AdditionalDependencies)
            {
                string name = dependency.GetMetadata("Name");
                // Don't add a new dependency if one already exists.
                if (returnDependenciesList.FirstOrDefault(rd => ((JProperty)rd).Name.Equals(name)) == null)
                {
                    string version = null;
                    if (externalPackageVersions != null)
                        version = externalPackageVersions.FirstOrDefault(epv => epv.ItemSpec.Equals(name, StringComparison.OrdinalIgnoreCase))?.GetMetadata("Version");

                    if (version == null)
                    {
                        NuGetVersion dependencyVersion = NuGetVersion.Parse(dependency.GetMetadata("Version"));
                        version = string.Join(".", dependencyVersion.Major, dependencyVersion.Minor, dependencyVersion.Patch);
                        if (!string.IsNullOrWhiteSpace(PackageBuildNumberOverride))
                        {
                            version += "-" + PackageBuildNumberOverride;
                        }
                    }
                    JProperty property = new JProperty(name, version);
                    returnDependenciesList.Add(property);
                }
                else
                {
                    Log.LogMessage("Ignoring AdditionalDependency '{0}', dependency is already present in {1}", name, ProjectJson);
                }
            }
            
            return new JObject(returnDependenciesList.ToArray());
        }