public static ProjectDigest[] DigestProjects(List <Dictionary <string, object> > projects, DependencySearchConfiguration depSearchConfig, ref string warningMsg) { List <ProjectDigest> projectDigests = new List <ProjectDigest>(); Dictionary <string, ProjectDigest> projDigestDictionary = new Dictionary <string, ProjectDigest>(); Dictionary <string, ProjectDigest> projDigestGuidDictionary = new Dictionary <string, ProjectDigest>(); foreach (Dictionary <string, object> project in projects) { DigestProject digestProject = _digestAlgoritms[(VisualStudioProjectTypeEnum)project["ProjectType"]]; ProjectDigest projDigest = digestProject(project, depSearchConfig); projectDigests.Add(projDigest); if (projDigestDictionary.ContainsKey(projDigest.ProjectName)) { throw new Exception("Projects with duplicated assembly names are not supported: " + projDigest.ProjectName); } log.DebugFormat("Digested project Name = {0}, GUID = {1}", projDigest.ProjectName, projDigest.ProjectGuid); projDigestDictionary.Add(projDigest.ProjectName, projDigest); projDigestGuidDictionary.Add(projDigest.ProjectGuid, projDigest); } List <ProjectDigest> tobeIncluded = new List <ProjectDigest>(); // verify if all project dependencies are in the solution foreach (ProjectDigest projectDigest in projectDigests) { foreach (ProjectReference projectReference in projectDigest.ProjectReferences) { string refName = projectReference.Name; if (!projDigestDictionary.ContainsKey(refName)) { Project prjRef = GetProject(projectReference.ProjectFullPath); if (prjRef == null) { // this might not be possible warningMsg = string.Format( "{0}\n Missing project reference {1} located at {2}!" + "\n Note this might cause a missing artifact dependency!", warningMsg, refName, projectReference.ProjectFullPath); continue; } DigestProject digestProject = _digestAlgoritms[VisualStudioProjectTypeEnum.Windows__CSharp]; Dictionary <string, object> projectMap = new Dictionary <string, object>(); projectMap.Add("Project", prjRef); ProjectDigest prjRefDigest = digestProject(projectMap, depSearchConfig); string errMsg = string.Format( "Project \"{0}\" requires \"{1}\" which is not included in the Solution File, " + "\nWould you like to include \"{1}\" Generating NPanday Project Poms?" + "\nNote: Not adding \"{1}\" will result to a missing Artifact Dependency \"{1}\"", projectDigest.ProjectName, prjRefDigest.ProjectName); // TODO: should not be in the importer DialogResult includeResult = MessageBox.Show(errMsg, "Include Project in Pom Generation:", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (includeResult == DialogResult.Yes) { projDigestDictionary.Add(prjRefDigest.ProjectName, prjRefDigest); tobeIncluded.Add(prjRefDigest); } else { warningMsg = string.Format( "{0}\n Please Make sure that Artifact[GroupId: {1}, ArtifactId: {1}] exists in your NPanday Repository, " + "\n Or an error will occur during NPanday-Build due to Missing Artifact Dependency!", warningMsg, prjRefDigest.ProjectName); } } } } // add tobe included projectDigests.AddRange(tobeIncluded); // insert the projectRererences foreach (ProjectDigest prjDigest in projectDigests) { if (prjDigest.ProjectReferences != null) { for (int i = 0; i < prjDigest.ProjectReferences.Length; i++) { ProjectReference prjRef = prjDigest.ProjectReferences[i]; if (projDigestDictionary.ContainsKey(prjRef.Name)) { ProjectDigest pd = projDigestDictionary[prjRef.Name]; prjRef.ProjectReferenceDigest = pd; } } } if (prjDigest.SilverlightApplicationList != null) { foreach (SilverlightApplicationReference app in prjDigest.SilverlightApplicationList) { if (!projDigestGuidDictionary.ContainsKey(app.Guid)) { throw new Exception("Silverlight application in the web application project must be included in the solution: " + app.ToString()); } app.Project = projDigestGuidDictionary[app.Guid]; } } } // sort by inter-project dependency projectDigests.Sort(CompareByDependency); return(projectDigests.ToArray()); }
public static ProjectDigest[] DigestProjects(List <Dictionary <string, object> > projects, ref string warningMsg) { List <ProjectDigest> projectDigests = new List <ProjectDigest>(); Dictionary <string, ProjectDigest> projDigestDictionary = new Dictionary <string, ProjectDigest>(); foreach (Dictionary <string, object> project in projects) { DigestProject digestProject = _digestAlgoritms[(VisualStudioProjectTypeEnum)project["ProjectType"]]; ProjectDigest projDigest = digestProject(project); projectDigests.Add(projDigest); projDigestDictionary.Add(projDigest.ProjectName, projDigest); } List <ProjectDigest> tobeIncluded = new List <ProjectDigest>(); // verify if all project dependencies are in the solution foreach (ProjectDigest projectDigest in projectDigests) { foreach (ProjectReference projectReference in projectDigest.ProjectReferences) { if (string.IsNullOrEmpty(projectReference.Name) || !projDigestDictionary.ContainsKey(projectReference.Name)) { Project prjRef = GetProject(projectReference.ProjectFullPath); if (prjRef == null) { // this might not be possible warningMsg = string.Format( "{0}\n Missing Project Reference {1} located at {2}!" + "\n Note this might cause Missing Artifact Dependency!", warningMsg, projectReference.Name, projectReference.ProjectFullPath); continue; } DigestProject digestProject = _digestAlgoritms[VisualStudioProjectTypeEnum.Windows__CSharp]; Dictionary <string, object> projectMap = new Dictionary <string, object>(); projectMap.Add("Project", prjRef); ProjectDigest prjRefDigest = digestProject(projectMap); string errMsg = string.Format( "Project \"{0}\" Requires \"{1}\" which is not included in the Solution File, " + "\nWould you like to include \"{1}\" Generating NPanday Project Poms?" + "\nNote: Not adding \"{1}\" will result to a missing Artifact Dependency \"{1}\"", projectDigest.ProjectName, prjRefDigest.ProjectName); DialogResult includeResult = MessageBox.Show(errMsg, "Include Project in Pom Generation:", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (includeResult == DialogResult.Yes) { projDigestDictionary.Add(prjRefDigest.ProjectName, prjRefDigest); tobeIncluded.Add(prjRefDigest); } else { warningMsg = string.Format( "{0}\n Please Make sure that Artifact[GroupId: {1}, ArtifactId: {1}] exists in your NPanday Repository, " + "\n Or an error will occur during NPanday-Build due to Missing Artifact Dependency!", warningMsg, prjRefDigest.ProjectName); } } } } // add tobe included projectDigests.AddRange(tobeIncluded); // insert the projectRererences foreach (ProjectDigest prjDigest in projectDigests) { if (prjDigest.ProjectReferences == null) { // if no project references proceed to the next loop continue; } for (int i = 0; i < prjDigest.ProjectReferences.Length; i++) { ProjectReference prjRef = prjDigest.ProjectReferences[i]; if (projDigestDictionary.ContainsKey(prjRef.Name)) { ProjectDigest pd = projDigestDictionary[prjRef.Name]; prjRef.ProjectReferenceDigest = pd; } } } // sort by inter-project dependency projectDigests.Sort(CompareByDependency); return(projectDigests.ToArray()); }