private void btnGenerate_Click(object sender, EventArgs e) { string configuration = null; if (configComboBox.SelectedItem != "(Default)") { configuration = (string)configComboBox.SelectedItem; } string cloudConfig = null; if (cloudConfigComboBox.SelectedItem != "(Default)") { cloudConfig = (string)cloudConfigComboBox.SelectedItem; } DependencySearchConfiguration depSearchConfig = new DependencySearchConfiguration(); depSearchConfig.SearchFramework = searchFrameworkCheckBox.Checked; depSearchConfig.SearchAssemblyFoldersEx = searchAssemblyFoldersExCheckBox.Checked; depSearchConfig.SearchGac = searchGacCheckBox.Checked; depSearchConfig.CopyToMaven = copyToMavenCheckBox.Checked; //Refactored code for easier Unit Testing try { GeneratePom(txtBrowseDotNetSolutionFile.Text, txtGroupId.Text.Trim(), txtVersion.Text.Trim(), txtSCMTag.Text, useMsDeployCheckBox.Checked, configuration, cloudConfig, depSearchConfig); } catch (Exception exception) { log.Debug("Import error", exception); MessageBox.Show(exception.Message, "NPanday Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 ProjectDigest DigestProject(Dictionary<string, object> projectMap, DependencySearchConfiguration depSearchConfig) { Project project = (Project)projectMap["Project"]; log.DebugFormat("Digesting project {0}", project.FullFileName); if (!projectMap.ContainsKey("ProjectType")) { if (project.FullFileName.ToUpper().EndsWith(".CSPROJ")) { projectMap.Add("ProjectType",VisualStudioProjectTypeEnum.Windows__CSharp); } else if (project.FullFileName.ToUpper().EndsWith(".VBPROJ")) { projectMap.Add("ProjectType", VisualStudioProjectTypeEnum.Windows__VbDotNet); } } ProjectDigest projectDigest = new ProjectDigest(); string projectBasePath = Path.GetDirectoryName(project.FullFileName); projectDigest.ProjectType = (VisualStudioProjectTypeEnum)projectMap["ProjectType"]; projectDigest.FullFileName = project.FullFileName; projectDigest.FullDirectoryName = Path.GetDirectoryName(project.FullFileName); if (projectMap.ContainsKey("Configuration")) projectDigest.Configuration = projectMap["Configuration"].ToString(); projectDigest.DependencySearchConfig = depSearchConfig; FileInfo existingPomFile = new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")); if (existingPomFile.Exists) { projectDigest.ExistingPom = PomHelperUtility.ReadPomAsModel(existingPomFile); } if ((projectDigest.ProjectType & VisualStudioProjectTypeEnum.Windows__CSharp) == VisualStudioProjectTypeEnum.Windows__CSharp) { projectDigest.Language = "csharp"; } else if ((projectDigest.ProjectType & VisualStudioProjectTypeEnum.Windows__VbDotNet) == VisualStudioProjectTypeEnum.Windows__VbDotNet) { projectDigest.Language = "vb"; } List<Reference> references = new List<Reference>(); List<ProjectReference> projectReferences = new List<ProjectReference>(); if (projectMap.ContainsKey("InterProjectReferences") && projectMap["InterProjectReferences"] != null && projectMap["InterProjectReferences"] is Microsoft.Build.BuildEngine.Project[] ) { Microsoft.Build.BuildEngine.Project[] interProjectReferences = (Microsoft.Build.BuildEngine.Project[])projectMap["InterProjectReferences"]; foreach (Microsoft.Build.BuildEngine.Project p in interProjectReferences) { ProjectReference prjRef = new ProjectReference(projectBasePath); prjRef.ProjectPath = p.FullFileName; prjRef.Name = GetProjectAssemblyName(Path.GetFullPath(prjRef.ProjectFullPath)); projectReferences.Add(prjRef); } } List<Compile> compiles = new List<Compile>(); List<None> nones = new List<None>(); List<WebReferenceUrl> webReferenceUrls = new List<WebReferenceUrl>(); List<Content> contents = new List<Content>(); List<WebReferences> webReferencesList = new List<WebReferences>(); List<EmbeddedResource> embeddedResources = new List<EmbeddedResource>(); List<BootstrapperPackage> bootstrapperPackages = new List<BootstrapperPackage>(); List<Folder> folders = new List<Folder>(); List<string> globalNamespaceImports = new List<string>(); List<ComReference> comReferenceList = new List<ComReference>(); DigestBuildProperties(project, projectDigest); DigestBuildItems(project, projectDigest, projectBasePath, projectReferences, references, compiles, nones, webReferenceUrls, contents, folders, webReferencesList, embeddedResources, bootstrapperPackages, globalNamespaceImports, comReferenceList); DigestImports(project); projectDigest.ProjectReferences = projectReferences.ToArray(); projectDigest.References = references.ToArray(); projectDigest.Compiles = compiles.ToArray(); projectDigest.Contents = contents.ToArray(); projectDigest.Nones = nones.ToArray(); projectDigest.WebReferenceUrls = webReferenceUrls.ToArray(); projectDigest.WebReferences = webReferencesList.ToArray(); projectDigest.EmbeddedResources = embeddedResources.ToArray(); projectDigest.BootstrapperPackages = bootstrapperPackages.ToArray(); projectDigest.Folders = folders.ToArray(); projectDigest.GlobalNamespaceImports = globalNamespaceImports.ToArray(); projectDigest.ComReferenceList = comReferenceList.ToArray(); return projectDigest; }
protected void GeneratePom(String solutionFile, String groupId, String version, String scmTag, bool useMsDeploy, string configuration, string cloudConfig, DependencySearchConfiguration depSearchConfig) { string warningMsg = string.Empty; String mavenVerRegex = "^[0-9]+(" + Regex.Escape(".") + "?[0-9]+){0,3}$"; String hasAlpha = "[a-zA-Z]"; String singleMavenVer = "[0-9]+"; bool isMatch = false; if (version.Length > 1) { if (Regex.IsMatch(version, hasAlpha) && version.ToUpper().EndsWith("-SNAPSHOT")) { isMatch = Regex.IsMatch(version.ToUpper().Replace("-SNAPSHOT", ""), mavenVerRegex, RegexOptions.Singleline); } else { isMatch = Regex.IsMatch(version, mavenVerRegex, RegexOptions.Singleline); } } else if (version.Length == 1) { isMatch = Regex.IsMatch(version, singleMavenVer); } if (!String.Empty.Equals(solutionFile) && System.IO.File.Exists(solutionFile) && (!String.Empty.Equals(groupId)) && (!String.Empty.Equals(version)) && isMatch) { // Generate here FileInfo file = new FileInfo(solutionFile); string artifactId = FilterID(ConvertToPascalCase(file.Name.Replace(".sln", ""))) + "-parent"; groupId = FilterID(groupId); if (scmTag == null) { scmTag = string.Empty; } if (scmTag.ToUpper().Contains("OPTIONAL")) { scmTag = string.Empty; } if (scmTag.Contains("scm:svn:")) { scmTag = scmTag.Remove(scmTag.IndexOf("scm:svn:"), 8); } try { if (!scmTag.Equals(string.Empty)) { if (!scmTag.Contains(@"://")) { scmTag = string.Format(@"http://{0}", scmTag); } Regex urlValidator = new Regex(@"^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?"); if (!urlValidator.IsMatch(scmTag)) { throw new Exception(string.Format("SCM tag {0} is incorrect format", scmTag)); } verifyRemoteAccess(scmTag, null); } } catch { if (DialogResult.Yes == MessageBox.Show(string.Format("SCM tag {0} was not accessible, would you still like to proceed with Project import?", scmTag), "SCM Tag", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { warningMsg = string.Format("\n The SCM URL {0} was added to the POM but could not be resolved and may not be valid.", scmTag); } else { return; } } validateSolutionStructure(); resyncAllArtifacts(); // TODO: nicer to have some sort of structure / flags for the Msdeploy bit, or this dialog will get out of control over time - perhaps a "project configuration" dialog can replace the test popup Dictionary <string, string> globalProperties = new Dictionary <string, string>(); globalProperties.Add("VisualStudioVersion", applicationObject.Version); string[] generatedPoms = ProjectImporter.NPandayImporter.ImportProject(file.FullName, groupId, artifactId, version, scmTag, true, useMsDeploy, configuration, cloudConfig, depSearchConfig, globalProperties, ref warningMsg); string str = string.Format("NPanday Import Project has Successfully Generated POM Files!\n"); foreach (string pom in generatedPoms) { str = str + string.Format("\n Generated Pom XML File: {0} ", pom); } if (!string.IsNullOrEmpty(warningMsg)) { str = string.Format("{0}\n\nwith Warning(s):{1}", str, warningMsg); } MessageBox.Show(str, this.Text); // Close the Dialog Here this.DialogResult = DialogResult.OK; this.Close(); } else { string message = (!(!"".Equals(solutionFile) && System.IO.File.Exists(solutionFile))) ? string.Format("Solution File Not Found: {0} ", solutionFile) : ""; if (String.IsNullOrEmpty(message)) { message = message + (String.IsNullOrEmpty(groupId) ? "Group Id is empty." : ""); } else { message = message + Environment.NewLine + (String.IsNullOrEmpty(groupId) ? "Group Id is empty." : ""); } //Adding error message for empty Version field if (String.IsNullOrEmpty(version)) { message += Environment.NewLine + "Version is empty."; } else if (!isMatch) { message += Environment.NewLine + "Version should be in the form major.minor.build.revision-SNAPSHOT"; } throw new Exception(message); } }
public ProjectDigest DigestProject(Dictionary<string, object> projectMap, DependencySearchConfiguration depSearchConfig) { ProjectDigest projectDigest = new ProjectDigest(); projectDigest.ProjectType = (VisualStudioProjectTypeEnum)projectMap["ProjectType"]; projectDigest.FullFileName = projectMap["ProjectFullPath"].ToString(); projectDigest.FullDirectoryName = projectDigest.FullFileName; if (projectMap.ContainsKey("TargetFramework")) projectDigest.TargetFramework = projectMap["TargetFramework"].ToString(); if (projectMap.ContainsKey("Configuration")) projectDigest.Configuration = projectMap["Configuration"].ToString(); projectDigest.DependencySearchConfig = depSearchConfig; FileInfo existingPomFile = new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")); if(existingPomFile.Exists) { projectDigest.ExistingPom = PomHelperUtility.ReadPomAsModel(existingPomFile); } // get Assembly name if (projectMap.ContainsKey("Release.AspNetCompiler.VirtualPath")) { projectDigest.Name = projectMap["Release.AspNetCompiler.VirtualPath"].ToString() .Replace(@"/", "") .Replace(@"\\", ""); } else if (projectMap.ContainsKey("Debug.AspNetCompiler.VirtualPath")) { projectDigest.Name = projectMap["Debug.AspNetCompiler.VirtualPath"].ToString() .Replace(@"/", "") .Replace(@"\\", ""); } else if(projectMap.ContainsKey("ProjectFullPath")) { projectDigest.Name = new DirectoryInfo(projectMap["ProjectFullPath"].ToString()).Name; } // InterProjectReferences List<ProjectReference> prjRefList = new List<ProjectReference>(); if (projectMap.ContainsKey("InterProjectReferences")) { foreach (Project var in (Project[])projectMap["InterProjectReferences"]) { ProjectReference prjRef = new ProjectReference(projectMap["ProjectFullPath"].ToString()); prjRef.Name = GetProjectAssemblyName(Path.GetFullPath(var.FullFileName)); prjRef.ProjectPath = Path.GetFullPath(var.FullFileName); prjRefList.Add(prjRef); } } projectDigest.ProjectReferences = prjRefList.ToArray(); //WebConfigAssemblies List<Reference> webConfigRefList = new List<Reference>(); //if (projectMap.ContainsKey("WebConfigAssemblies")) //{ // foreach (string var in (string[]) projectMap["WebConfigAssemblies"]) // { // Reference reference = new Reference(projectMap["ProjectFullPath"].ToString(), gac); // reference.AssemblyInfo = var; // webConfigRefList.Add(reference); // } //} //WebReferenceURL //if (projectMap.ContainsKey("WebReferencesUrl")) //{ // List<WebReferenceUrl> webReferenceUrls = new List<WebReferenceUrl>(); // if (projectDigest.WebReferenceUrls != null && projectDigest.WebReferenceUrls.Length > 0) // { // webReferenceUrls.AddRange(projectDigest.WebReferenceUrls); // } // foreach (WebReferenceUrl webReferenceUrl in (WebReferenceUrl[])projectMap["WebReferencesUrl"]) // { // if (webReferenceUrl != null && !string.IsNullOrEmpty(webReferenceUrl.RelPath) && !string.IsNullOrEmpty(webReferenceUrl.UpdateFromURL)) // webReferenceUrls.Add(webReferenceUrl); // } // projectDigest.WebReferenceUrls = webReferenceUrls.ToArray(); //} //BinAssemblies List<Reference> binRefList = new List<Reference>(); //if (projectMap.ContainsKey("BinAssemblies")) //{ // foreach (string var in (string[])projectMap["BinAssemblies"]) // { // // exclude if its already in the webconfig // Reference reference = new Reference(projectMap["ProjectFullPath"].ToString(), gac); // reference.HintPath = var; // // check if its not in project-reference or webconfig-assemblies references // if (!ReferenceInReferenceList(reference, webConfigRefList) && !ReferenceInProjectReferenceList(reference, prjRefList)) // { // binRefList.Add(reference); // } // } //} // combine both web and bin assemblies List<Reference> referenceList = new List<Reference>(); //referenceList.AddRange(webConfigRefList); //referenceList.AddRange(binRefList); projectDigest.References = referenceList.ToArray(); return projectDigest; }
public ProjectDigest DigestProject(Dictionary <string, object> projectMap, DependencySearchConfiguration depSearchConfig) { Project project = (Project)projectMap["Project"]; log.DebugFormat("Digesting project {0}", project.FullFileName); if (!projectMap.ContainsKey("ProjectType")) { if (project.FullFileName.ToUpper().EndsWith(".CSPROJ")) { projectMap.Add("ProjectType", VisualStudioProjectTypeEnum.Windows__CSharp); } else if (project.FullFileName.ToUpper().EndsWith(".VBPROJ")) { projectMap.Add("ProjectType", VisualStudioProjectTypeEnum.Windows__VbDotNet); } } ProjectDigest projectDigest = new ProjectDigest(); string projectBasePath = Path.GetDirectoryName(project.FullFileName); projectDigest.ProjectType = (VisualStudioProjectTypeEnum)projectMap["ProjectType"]; projectDigest.FullFileName = project.FullFileName; projectDigest.FullDirectoryName = Path.GetDirectoryName(project.FullFileName); if (projectMap.ContainsKey("Configuration")) { projectDigest.Configuration = projectMap["Configuration"].ToString(); } projectDigest.DependencySearchConfig = depSearchConfig; FileInfo existingPomFile = new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")); if (existingPomFile.Exists) { projectDigest.ExistingPom = PomHelperUtility.ReadPomAsModel(existingPomFile); } if ((projectDigest.ProjectType & VisualStudioProjectTypeEnum.Windows__CSharp) == VisualStudioProjectTypeEnum.Windows__CSharp) { projectDigest.Language = "csharp"; } else if ((projectDigest.ProjectType & VisualStudioProjectTypeEnum.Windows__VbDotNet) == VisualStudioProjectTypeEnum.Windows__VbDotNet) { projectDigest.Language = "vb"; } List <Reference> references = new List <Reference>(); List <ProjectReference> projectReferences = new List <ProjectReference>(); if (projectMap.ContainsKey("InterProjectReferences") && projectMap["InterProjectReferences"] != null && projectMap["InterProjectReferences"] is Microsoft.Build.BuildEngine.Project[] ) { Microsoft.Build.BuildEngine.Project[] interProjectReferences = (Microsoft.Build.BuildEngine.Project[])projectMap["InterProjectReferences"]; foreach (Microsoft.Build.BuildEngine.Project p in interProjectReferences) { ProjectReference prjRef = new ProjectReference(projectBasePath); prjRef.ProjectPath = p.FullFileName; prjRef.Name = GetProjectAssemblyName(Path.GetFullPath(prjRef.ProjectFullPath)); projectReferences.Add(prjRef); } } List <Compile> compiles = new List <Compile>(); List <None> nones = new List <None>(); List <WebReferenceUrl> webReferenceUrls = new List <WebReferenceUrl>(); List <Content> contents = new List <Content>(); List <WebReferences> webReferencesList = new List <WebReferences>(); List <EmbeddedResource> embeddedResources = new List <EmbeddedResource>(); List <BootstrapperPackage> bootstrapperPackages = new List <BootstrapperPackage>(); List <Folder> folders = new List <Folder>(); List <string> globalNamespaceImports = new List <string>(); List <ComReference> comReferenceList = new List <ComReference>(); DigestBuildProperties(project, projectDigest); DigestBuildItems(project, projectDigest, projectBasePath, projectReferences, references, compiles, nones, webReferenceUrls, contents, folders, webReferencesList, embeddedResources, bootstrapperPackages, globalNamespaceImports, comReferenceList); DigestImports(project); projectDigest.ProjectReferences = projectReferences.ToArray(); projectDigest.References = references.ToArray(); projectDigest.Compiles = compiles.ToArray(); projectDigest.Contents = contents.ToArray(); projectDigest.Nones = nones.ToArray(); projectDigest.WebReferenceUrls = webReferenceUrls.ToArray(); projectDigest.WebReferences = webReferencesList.ToArray(); projectDigest.EmbeddedResources = embeddedResources.ToArray(); projectDigest.BootstrapperPackages = bootstrapperPackages.ToArray(); projectDigest.Folders = folders.ToArray(); projectDigest.GlobalNamespaceImports = globalNamespaceImports.ToArray(); projectDigest.ComReferenceList = comReferenceList.ToArray(); return(projectDigest); }
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 ProjectDigest DigestProject(Dictionary <string, object> projectMap, DependencySearchConfiguration depSearchConfig) { ProjectDigest projectDigest = new ProjectDigest(); projectDigest.ProjectType = (VisualStudioProjectTypeEnum)projectMap["ProjectType"]; projectDigest.FullFileName = projectMap["ProjectFullPath"].ToString(); projectDigest.FullDirectoryName = projectDigest.FullFileName; if (projectMap.ContainsKey("TargetFramework")) { projectDigest.TargetFramework = projectMap["TargetFramework"].ToString(); } if (projectMap.ContainsKey("Configuration")) { projectDigest.Configuration = projectMap["Configuration"].ToString(); } projectDigest.DependencySearchConfig = depSearchConfig; FileInfo existingPomFile = new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml")); if (existingPomFile.Exists) { projectDigest.ExistingPom = PomHelperUtility.ReadPomAsModel(existingPomFile); } // get Assembly name if (projectMap.ContainsKey("Release.AspNetCompiler.VirtualPath")) { projectDigest.Name = projectMap["Release.AspNetCompiler.VirtualPath"].ToString() .Replace(@"/", "") .Replace(@"\\", ""); } else if (projectMap.ContainsKey("Debug.AspNetCompiler.VirtualPath")) { projectDigest.Name = projectMap["Debug.AspNetCompiler.VirtualPath"].ToString() .Replace(@"/", "") .Replace(@"\\", ""); } else if (projectMap.ContainsKey("ProjectFullPath")) { projectDigest.Name = new DirectoryInfo(projectMap["ProjectFullPath"].ToString()).Name; } // InterProjectReferences List <ProjectReference> prjRefList = new List <ProjectReference>(); if (projectMap.ContainsKey("InterProjectReferences")) { foreach (Project var in (Project[])projectMap["InterProjectReferences"]) { ProjectReference prjRef = new ProjectReference(projectMap["ProjectFullPath"].ToString()); prjRef.Name = GetProjectAssemblyName(Path.GetFullPath(var.FullFileName)); prjRef.ProjectPath = Path.GetFullPath(var.FullFileName); prjRefList.Add(prjRef); } } projectDigest.ProjectReferences = prjRefList.ToArray(); //WebConfigAssemblies List <Reference> webConfigRefList = new List <Reference>(); //if (projectMap.ContainsKey("WebConfigAssemblies")) //{ // foreach (string var in (string[]) projectMap["WebConfigAssemblies"]) // { // Reference reference = new Reference(projectMap["ProjectFullPath"].ToString(), gac); // reference.AssemblyInfo = var; // webConfigRefList.Add(reference); // } //} //WebReferenceURL //if (projectMap.ContainsKey("WebReferencesUrl")) //{ // List<WebReferenceUrl> webReferenceUrls = new List<WebReferenceUrl>(); // if (projectDigest.WebReferenceUrls != null && projectDigest.WebReferenceUrls.Length > 0) // { // webReferenceUrls.AddRange(projectDigest.WebReferenceUrls); // } // foreach (WebReferenceUrl webReferenceUrl in (WebReferenceUrl[])projectMap["WebReferencesUrl"]) // { // if (webReferenceUrl != null && !string.IsNullOrEmpty(webReferenceUrl.RelPath) && !string.IsNullOrEmpty(webReferenceUrl.UpdateFromURL)) // webReferenceUrls.Add(webReferenceUrl); // } // projectDigest.WebReferenceUrls = webReferenceUrls.ToArray(); //} //BinAssemblies List <Reference> binRefList = new List <Reference>(); //if (projectMap.ContainsKey("BinAssemblies")) //{ // foreach (string var in (string[])projectMap["BinAssemblies"]) // { // // exclude if its already in the webconfig // Reference reference = new Reference(projectMap["ProjectFullPath"].ToString(), gac); // reference.HintPath = var; // // check if its not in project-reference or webconfig-assemblies references // if (!ReferenceInReferenceList(reference, webConfigRefList) && !ReferenceInProjectReferenceList(reference, prjRefList)) // { // binRefList.Add(reference); // } // } //} // combine both web and bin assemblies List <Reference> referenceList = new List <Reference>(); //referenceList.AddRange(webConfigRefList); //referenceList.AddRange(binRefList); projectDigest.References = referenceList.ToArray(); return(projectDigest); }