public static void SyncronizePomValues(ref ProjectDigest[] projectDigests, ProjectStructureType structureType, string solutionFile, ref string groupId, ref string artifactId, ref string version)
        {
            // sync parent values
            if (structureType != ProjectStructureType.FlatSingleModuleProject)
            {
                SyncParentValues(structureType, solutionFile, ref groupId, ref artifactId, ref version);
            }
            else
            {
                // get the group id from the solution file
                if (projectDigests[0].ExistingPom != null)
                {
                    groupId = projectDigests[0].ExistingPom.groupId;
                    version = projectDigests[0].ExistingPom.version;
                }
                else
                {
                    throw new Exception("Project Must be Imported atleast once before Re-Importing!");
                }
            }

            // syncronize each project to existing poms
            for (int i=0; i<projectDigests.Length; i++)
            {
                SyncProjectValues(ref projectDigests[i]);
            }

            // show test verification if there is a new project added
            if (IsProjectHavingANewImportedProject(projectDigests))
            {
                VerifyUnitTestsForm verifyForm = new VerifyUnitTestsForm(projectDigests);
                verifyForm.ShowDialog();
            }
        }
Example #2
0
 public void CheckedProject(ref ProjectDigest[] projectDigests, ProjectStructureType structureType, string solutionFile, ref string groupId, ref string artifactId, ref string version)
 {
     foreach (ProjectDigest pDigest in projectDigests)
     {
         pDigest.UnitTest = true;
     }
 }
Example #3
0
 public override string[] ImportProjectType(ProjectDigest[] prjDigests, string solutionFile, string groupId, string artifactId, string version, string scmTag, bool writePom, List<Reference> missingReferences, List<string> nonPortableReferences)
 {
     if (prjDigests.Length.Equals(0))
     {
         throw new Exception("Sorry, but there are no Supported Projects Found");
     }
     else
     {
         throw new Exception("The Project Structure is malformed or abnormal!, Project Importer Could not support this project Structure.");
     }
 }
Example #4
0
        public static ProjectStructureType GetProjectStructureType(string solutionFile, ProjectDigest[] projectDigests)
        {
            if (solutionFile == null)
            {
                throw new NullReferenceException("Solution file must not be null!");
            }

            if (projectDigests == null)
            {
                throw new NullReferenceException("Project Digests Must not be null!");
            }

            string solutonDir = Path.GetDirectoryName(Path.GetFullPath(solutionFile));

            if (IsProjectAbnormal(projectDigests))
            {
                return ProjectStructureType.AbnormalProject;
            }
            else if (projectDigests.Length == 1)
            {

                if (IsSameDirectory(solutonDir, projectDigests[0].FullDirectoryName))
                {
                    // if the project path is the same as the solution path
                    // then it is a flat single module project
                    return ProjectStructureType.FlatSingleModuleProject;
                }

                // else its just a normal project
                return ProjectStructureType.NormalSingleProject;
            }
            else if (projectDigests.Length > 1)
            {
                foreach (ProjectDigest prjDigest in projectDigests)
                {
                    if (IsSameDirectory(prjDigest.FullDirectoryName, solutonDir))
                    {
                        // project has same directory as the solution file
                        return ProjectStructureType.FlatMultiModuleProject;
                    }
                }

                return ProjectStructureType.NormalMultiModuleProject;
            }
            else
            {
                // solutin must have atleast 1 project
                return ProjectStructureType.AbnormalProject;
            }
        }
Example #5
0
        public override string[] ImportProjectType(ProjectDigest[] prjDigests, string solutionFile, string groupId, string artifactId, string version, string scmTag, bool writePom, List<Reference> missingReferences, List<string> nonPortableReferences)
        {
            List<string> generatedPoms = new List<string>();

            string pomFileName = Path.GetFullPath(Path.GetDirectoryName(solutionFile) + @"\pom.xml");
            // write the parent pom
            NPanday.Model.Pom.Model mainModel = PomConverter.MakeProjectsParentPomModel(prjDigests, pomFileName, groupId, artifactId, version, scmTag, true);
            generatedPoms.Add(pomFileName);

            generatedPoms.AddRange(
                GenerateChildPoms(prjDigests, groupId, pomFileName, mainModel, writePom, scmTag, missingReferences, nonPortableReferences)
            );

            return generatedPoms.ToArray();
        }
        public string[] GenerateChildPoms(ProjectDigest[] prjDigests, string groupId, string parentPomFilename, NPanday.Model.Pom.Model parentPomModel, bool writePom, string scmTag, List<Reference> missingReferences, List<string> nonPortableReferences)
        {
            List<string> generatedPoms = new List<string>();

            // make the child pom
            NPanday.Model.Pom.Model[] models = PomConverter.ConvertProjectsToPomModels(prjDigests, parentPomFilename, parentPomModel, groupId, writePom, scmTag, missingReferences, nonPortableReferences);

            if (models != null && models.Length > 0)
            {
                foreach (ProjectDigest prj in prjDigests)
                {
                    string fileDir = Path.GetDirectoryName(prj.FullFileName);
                    string pomFile = Path.GetFullPath(fileDir + @"\pom.xml");
                    generatedPoms.Add(pomFile);
                }

            }

            return generatedPoms.ToArray();
        }
        public AbstractPomConverter(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId)
        {
            artifactContext = new ArtifactContext();
            this.projectDigest = projectDigest;
            this.mainPomFile = mainPomFile;
            this.parent = parent;
            this.groupId = FilterID(groupId);
            this.version = parent != null ? parent.version : null;

            this.rspUtil = new RspUtility();
            this.model = new NPanday.Model.Pom.Model();

            // Add build Tag
            this.model.build = new NPanday.Model.Pom.Build();

            this.missingReferences = new List<Reference>();
            this.nonPortableReferences = new List<string>();

            // TODO: this is a hack because of bad design. The things that talk to the local repository should be pulled out of here, and able to be stubbed/mocked instead
            if (testingArtifacts != null)
            {
                this.localArtifacts = testingArtifacts;
            }
        }
        private static void processProperty(ProjectDigest projectDigest, BuildProperty buildProperty)
        {
            if ("RootNameSpace".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.RootNamespace = buildProperty.Value;
            }
            else if ("AssemblyName".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.AssemblyName = buildProperty.Value;
            }
            else if ("Name".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.Name = buildProperty.Value;
            }
            else if ("StartupObject".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.StartupObject = buildProperty.Value;
            }
            else if ("OutputType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.OutputType = buildProperty.Value;
            }
            else if ("HostInBrowser".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.HostInBrowser = bool.Parse(buildProperty.Value);
            }
            else if ("SilverlightVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.SilverlightVersion = buildProperty.Value.Replace("$(TargetFrameworkVersion)", projectDigest.TargetFrameworkVersion);
                // BusinessApplication template doesn't set the target framework identifier, which we need to find the right things later
                projectDigest.TargetFrameworkIdentifier = "Silverlight";
            }
            else if ("SilverlightApplication".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.SilverlightApplication = bool.Parse(buildProperty.Value);
            }
            else if ("SilverlightApplicationList".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.SilverlightApplicationList = SilverlightApplicationReference.parseApplicationList(buildProperty.Value);
            }
            else if ("RoleType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.RoleType = buildProperty.Value;
            }
            else if ("SignAssembly".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.SignAssembly = buildProperty.Value;
            }
            else if ("AssemblyOriginatorKeyFile".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.AssemblyOriginatorKeyFile = buildProperty.Value;
            }
            else if ("DelaySign".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.DelaySign = buildProperty.Value;
            }
            else if ("Optimize".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.Optimize = buildProperty.Value;
            }
            else if ("AllowUnsafeBlocks".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.AllowUnsafeBlocks = buildProperty.Value;
            }
            else if ("DefineConstants".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.DefineConstants = buildProperty.Value;
            }
            else if ("ApplicationIcon".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.ApplicationIcon = buildProperty.Value;
            }
            else if ("Win32Resource".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.Win32Resource = buildProperty.Value;
            }
            else if ("ProjectGuid".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.ProjectGuid = buildProperty.Value;
            }
            else if ("Configuration".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.Configuration = buildProperty.Value;
            }
            else if ("BaseIntermediateOutputPath".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.BaseIntermediateOutputPath = buildProperty.Value;
            }
            else if ("OutputPath".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.OutputPath = buildProperty.Value;
            }
            else if ("TreatWarningsAsErrors".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.TreatWarningsAsErrors = buildProperty.Value;
            }
            else if ("Platform".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.Platform = buildProperty.Value;
            }
            else if ("ProductVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.ProductVersion = buildProperty.Value;
            }
            else if ("SchemaVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.SchemaVersion = buildProperty.Value;
            }
            else if ("TargetFrameworkIdentifier".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.TargetFrameworkIdentifier = buildProperty.Value;
            }
            else if ("TargetFrameworkProfile".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.TargetFrameworkProfile = buildProperty.Value;
            }
            else if ("TargetFrameworkVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase) && projectDigest.TargetFramework == null)
            {
                // Raw value from project
                projectDigest.TargetFrameworkVersion = buildProperty.Value;

                // changed the version to the more specific version
                string frameworkVersion = buildProperty.Value.Substring(1);

                if ("2.0".Equals(frameworkVersion))
                {
                    frameworkVersion = "2.0.50727";
                }

                projectDigest.TargetFramework = frameworkVersion;
            }
            else if ("AppDesignerFolder".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.AppDesignerFolder = buildProperty.Value;
            }
            else if ("DebugSymbols".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.DebugSymbols = buildProperty.Value;
            }
            else if ("DebugType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.DebugType = buildProperty.Value;
            }
            else if ("ErrorReport".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.ErrorReport = buildProperty.Value;
            }
            else if ("WarningLevel".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.WarningLevel = buildProperty.Value;
            }
            else if ("DocumentationFile".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.DocumentationFile = buildProperty.Value;
            }
            else if ("PostBuildEvent".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.PostBuildEvent = buildProperty.Value;
            }
            else if ("PublishUrl".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.PublishUrl = buildProperty.Value;
            }
            else if ("Install".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.Install = buildProperty.Value;
            }
            else if ("InstallFrom".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.InstallFrom = buildProperty.Value;
            }
            else if ("UpdateEnabled".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.UpdateEnabled = buildProperty.Value;
            }
            else if ("UpdateMode".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.UpdateMode = buildProperty.Value;
            }
            else if ("UpdateInterval".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.UpdateInterval = buildProperty.Value;
            }
            else if ("UpdateIntervalUnits".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.UpdateIntervalUnits = buildProperty.Value;
            }
            else if ("UpdatePeriodically".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.UpdatePeriodically = buildProperty.Value;
            }
            else if ("UpdateRequired".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.UpdateRequired = buildProperty.Value;
            }
            else if ("MapFileExtensions".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.MapFileExtensions = buildProperty.Value;
            }
            else if ("ApplicationVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.ApplicationVersion = buildProperty.Value;
            }
            else if ("IsWebBootstrapper".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.IsWebBootstrapper = buildProperty.Value;
            }
            else if ("BootstrapperEnabled".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.BootstrapperEnabled = buildProperty.Value;
            }
            else if ("PreBuildEvent".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.PreBuildEvent = buildProperty.Value;
            }
            else if ("MyType".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.MyType = buildProperty.Value;
            }
            else if ("DefineDebug".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.DefineDebug = buildProperty.Value;
            }
            else if ("DefineTrace".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.DefineTrace = buildProperty.Value;
            }
            else if ("NoWarn".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.NoWarn = buildProperty.Value;
            }
            else if ("WarningsAsErrors".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                projectDigest.WarningsAsErrors = buildProperty.Value;
            }
            else if ("ProjectTypeGuids".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
            {
                if (!string.IsNullOrEmpty(buildProperty.Value))
                {
                    projectDigest.ProjectType = VisualStudioProjectType.GetVisualStudioProjectType(buildProperty.Value);
                }
            }
            else
            {
                log.Debug("Unhandled Property:" + buildProperty.Name);
            }
        }
        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;
        }
 private static void DigestBuildProperties(Project project, ProjectDigest projectDigest)
 {
     foreach (BuildPropertyGroup buildPropertyGroup in project.PropertyGroups)
     {
         if (string.IsNullOrEmpty(buildPropertyGroup.Condition) || evaluateCondition(projectDigest, buildPropertyGroup.Condition))
         {
             foreach (BuildProperty buildProperty in buildPropertyGroup)
             {
                 if (!buildProperty.IsImported)
                 {
                     if (!string.IsNullOrEmpty(buildProperty.Condition))
                     {
                         log.DebugFormat("Property {0} = {1} if {2}", buildProperty.Name, buildProperty.Value, buildProperty.Condition);
                         if (evaluateCondition(projectDigest, buildProperty.Condition))
                         {
                             processProperty(projectDigest, buildProperty);
                         }
                     }
                     else
                     {
                         log.DebugFormat("Property {0} = {1}", buildProperty.Name, buildProperty.Value);
                         processProperty(projectDigest, buildProperty);
                     }
                 }
             }
         }
     }
 }
        private static bool evaluateCondition(ProjectDigest projectDigest, string condition)
        {
            // basic evaluation of conditions, unable to find a MSBuild API to do it - many will not be supported

            bool val = true;

            string newCond = condition.Replace("$(Configuration)", projectDigest.Configuration);
            newCond = newCond.Replace("$(Platform)", projectDigest.Platform);
            newCond = newCond.Replace("$(Language)", projectDigest.Language);

            if (newCond.Contains("$("))
            {
                log.DebugFormat("Unable to evaluation condition: {0}, unrecognized expression, assuming 'true'", newCond);
                return true;
            }

            Match match = Regex.Match(newCond, @"^\s*'(.*)'\s*(==|!=)\s*'(.*)'\s*$");
            if (match.Success)
            {
                string op = match.Groups[2].Value;
                if (op == "==")
                {
                    val = match.Groups[1].Value == match.Groups[3].Value;
                }
                else if (op == "!=")
                {
                    val = match.Groups[1].Value != match.Groups[3].Value;
                }
                else
                {
                    log.WarnFormat("Unable to evaluate condition: {0}, unrecognized operator {1}, assuming 'true'", condition, op);
                }
            }
            else
            {
                log.WarnFormat("Unable to parse condition: {0}, assuming 'true'", condition);
            }

            log.DebugFormat("Condition = {0}, Substituted = {1}, Result = {2}", condition, newCond, val);
            return val;
        }
        private static void SyncProjectValues(ref ProjectDigest projectDigest)
        {
            FileInfo pomFile = new FileInfo(Path.Combine(projectDigest.FullDirectoryName, "pom.xml"));

            if (projectDigest.ExistingPom == null || !pomFile.Exists)
            {
                return;
            }

            NPanday.Model.Pom.Model model = NPanday.Utils.PomHelperUtility.ReadPomAsModel(pomFile);

            projectDigest.UnitTest = IsProjectAnIntegrationTest(model);
        }
        private static void DigestBuildItems(Project project, ProjectDigest projectDigest, string projectBasePath, ICollection<ProjectReference> projectReferences, ICollection<Reference> references, ICollection<Compile> compiles, ICollection<None> nones, ICollection<WebReferenceUrl> webReferenceUrls, ICollection<Content> contents, ICollection<Folder> folders, ICollection<WebReferences> webReferencesList, ICollection<EmbeddedResource> embeddedResources, ICollection<BootstrapperPackage> bootstrapperPackages, ICollection<string> globalNamespaceImports, IList<ComReference> comReferenceList)
        {
            string targetFramework = projectDigest.TargetFramework != null ? projectDigest.TargetFramework.Substring(0,3) : "2.0";
            RspUtility rsp = new RspUtility();
            foreach (BuildItemGroup buildItemGroup in project.ItemGroups)
            {
                foreach (BuildItem buildItem in buildItemGroup)
                {
                    if (!buildItem.IsImported)
                    {

                        switch (buildItem.Name)
                        {
                            case "ProjectReference":
                                ProjectReference prjRef = new ProjectReference(projectBasePath);
                                prjRef.ProjectPath = buildItem.Include;
                                prjRef.Name = GetProjectAssemblyName(Path.GetFullPath(prjRef.ProjectFullPath));
                                prjRef.RoleType = buildItem.GetMetadata("RoleType");
                                projectReferences.Add(prjRef);
                                break;
                            case "Reference":
                                // TODO: significant refactoring needed here - it should be calling the same resolution code that is in
                                //   AbstractPomConverter to find the right artifact based on the simple name

                                Reference reference = new Reference(projectBasePath);
                                //set processorArchitecture property to platform, it will be used by GacUtility in
                                // order to resolve artifact to right processor architecture
                                if (!string.IsNullOrEmpty(projectDigest.Platform))
                                {
                                    reference.ProcessorArchitecture = projectDigest.Platform;
                                }
                                string hintPath = buildItem.GetMetadata("HintPath");
                                if (!string.IsNullOrEmpty(hintPath))
                                {
                                    string fullHint = Path.Combine(projectBasePath, hintPath);
                                    if(File.Exists(fullHint))
                                        reference.HintPath = Path.GetFullPath(fullHint);
                                    else
                                        reference.HintPath = fullHint;
                                    SetReferenceFromFile(new FileInfo(fullHint), reference);
                                }
                                if ((string.IsNullOrEmpty(reference.HintPath) || !(new FileInfo(reference.HintPath).Exists)) && !rsp.IsRspIncluded(buildItem.Include, projectDigest.Language))
                                {
                                    if (buildItem.Include.Contains(","))
                                    {
                                        // complete name
                                        reference.SetAssemblyInfoValues(buildItem.Include);
                                    }
                                    else if (projectDigest.DependencySearchConfig.SearchGac && projectDigest.TargetFrameworkIdentifier != "Silverlight")
                                    {
                                        // simple name needs to be resolved
                                        List<string> refs = GacUtility.GetInstance().GetAssemblyInfo(buildItem.Include, null, null);
                                        if (refs.Count == 0)
                                        {
                                            log.Warn("Unable to find reference '" + buildItem.Include + "' in " + string.Join("; ", refs.ToArray()));
                                        }
                                        else if (refs.Count > 1)
                                        {
                                            string best = null;
                                            string bestFramework = "0.0";
                                            foreach (string s in refs)
                                            {
                                                try
                                                {
                                                    Assembly a = Assembly.ReflectionOnlyLoad(s);
                                                    string framework = a.ImageRuntimeVersion.Substring(1, 3);
                                                    if (framework.CompareTo(targetFramework) <= 0 && framework.CompareTo(bestFramework) > 0)
                                                    {
                                                        best = s;
                                                        bestFramework = framework;
                                                    }
                                                }
                                                catch (Exception e)
                                                {
                                                    // skip this assembly
                                                    log.Error("An error occurred loading assembly '" + s + "' - check that your PATH to gacutil matches your runtime environment: " + e.Message);
                                                }
                                            }
                                            reference.SetAssemblyInfoValues(best);
                                        }
                                        else
                                        {
                                            reference.SetAssemblyInfoValues(refs[0]);
                                        }
                                    }
                                    else
                                    {
                                        reference.Name = buildItem.Include;
                                    }
                                }
                                if ("NUnit.Framework".Equals(reference.Name, StringComparison.OrdinalIgnoreCase))
                                {
                                    reference.Name = "NUnit.Framework";
                                    projectDigest.UnitTest = true;
                                }
                                if (!string.IsNullOrEmpty(reference.Name))
                                {
                                    references.Add(reference);
                                }
                                break;
                            case "Compile":
                                Compile compile = new Compile(projectBasePath);
                                compile.IncludePath = buildItem.Include;
                                compile.AutoGen = buildItem.GetMetadata("AutoGen");
                                compile.DesignTimeSharedInput = buildItem.GetMetadata("DesignTimeSharedInput");
                                compile.DependentUpon = buildItem.GetMetadata("DependentUpon");
                                compile.DesignTime = buildItem.GetMetadata("DesignTime");
                                compile.SubType = buildItem.GetMetadata("SubType");
                                compiles.Add(compile);
                                break;
                            case "None":
                                None none = new None(projectBasePath);
                                none.IncludePath = buildItem.Include;

                                none.Link = buildItem.GetMetadata("Link");

                                none.Generator = buildItem.GetMetadata("Generator");
                                none.LastGenOutput = buildItem.GetMetadata("LastGenOutput");
                                none.DependentUpon = buildItem.GetMetadata("DependentUpon");

                                nones.Add(none);

                                //add included web reference when reimporting
                                if (buildItem.Include.Contains(".wsdl"))
                                {
                                    string path = Path.GetDirectoryName(buildItem.Include) + "\\";

                                    WebReferenceUrl webUrl = new WebReferenceUrl();
                                    webUrl.UrlBehavior = "Dynamic";
                                    webUrl.RelPath = path;

                                    if (!webRefExists(webUrl, webReferenceUrls))
                                    {
                                        webReferenceUrls.Add(webUrl);
                                    }

                                }
                                break;
                            case "WebReferenceUrl":
                                WebReferenceUrl web = new WebReferenceUrl();
                                web.UrlBehavior = buildItem.GetMetadata("UrlBehavior");
                                web.RelPath = buildItem.GetMetadata("RelPath");
                                web.UpdateFromURL = buildItem.GetMetadata("UpdateFromURL");
                                web.ServiceLocationURL = buildItem.GetMetadata("ServiceLocationURL");
                                web.CachedDynamicPropName = buildItem.GetMetadata("CachedDynamicPropName");
                                web.CachedAppSettingsObjectName = buildItem.GetMetadata("CachedAppSettingsObjectName");
                                web.CachedSettingsPropName = buildItem.GetMetadata("CachedSettingsPropName");

                                if (!webRefExists(web, webReferenceUrls))
                                {
                                    webReferenceUrls.Add(web);
                                }
                                break;
                            case "COMReference":
                                ComReference comRef = new ComReference();
                                comRef.Include = buildItem.Include;
                                comRef.Guid = buildItem.GetMetadata("Guid");
                                comRef.VersionMajor = buildItem.GetMetadata("VersionMajor");
                                comRef.VersionMinor = buildItem.GetMetadata("VersionMinor");
                                comRef.Lcid = buildItem.GetMetadata("Lcid");
                                comRef.Isolated = buildItem.GetMetadata("Isolated");
                                comRef.WrapperTool = buildItem.GetMetadata("WrapperTool");
                                comReferenceList.Add(comRef);
                                break;
                            case "Content":
                                Content content = new Content(projectBasePath);
                                content.IncludePath = buildItem.Include;
                                contents.Add(content);

                                //add web reference in <includes> tag of compile-plugin
                                if (content.IncludePath.Contains("Web References"))
                                {
                                    Compile compileWebRef = new Compile(projectBasePath);
                                    compileWebRef.IncludePath = buildItem.Include;
                                    compiles.Add(compileWebRef);
                                }
                                break;
                            case "Folder":
                                Folder folder = new Folder(projectBasePath);
                                folder.IncludePath = buildItem.Include;
                                folders.Add(folder);
                                break;
                            case "WebReferences":
                                WebReferences webReferences = new WebReferences(projectBasePath);
                                webReferences.IncludePath = buildItem.Include;
                                webReferencesList.Add(webReferences);
                                break;
                            case "EmbeddedResource":
                                EmbeddedResource embeddedResource = new EmbeddedResource(projectBasePath);
                                embeddedResource.IncludePath = buildItem.Include;

                                embeddedResource.DependentUpon = buildItem.GetMetadata("DependentUpon");
                                embeddedResource.SubType = buildItem.GetMetadata("SubType");
                                embeddedResource.Generator = buildItem.GetMetadata("Generator");
                                embeddedResource.LastGenOutput = buildItem.GetMetadata("LastGenOutput");
                                embeddedResource.WithCulture = buildItem.GetMetadata("WithCulture");
                                if (string.IsNullOrEmpty(embeddedResource.WithCulture))
                                {
                                    embeddedResource.WithCulture = MSBuildUtils.DetermineResourceCulture(buildItem.Include);
                                }

                                embeddedResources.Add(embeddedResource);
                                break;
                            case "BootstrapperPackage":
                                BootstrapperPackage bootstrapperPackage = new BootstrapperPackage(projectBasePath);
                                bootstrapperPackage.IncludePath = buildItem.Include;
                                bootstrapperPackage.Visible = buildItem.GetMetadata("Visible");
                                bootstrapperPackage.ProductName = buildItem.GetMetadata("ProductName");
                                bootstrapperPackage.Install = buildItem.GetMetadata("Install");

                                bootstrapperPackages.Add(bootstrapperPackage);
                                break;
                            case "Import":
                                globalNamespaceImports.Add(buildItem.Include);
                                break;
                            case "BaseApplicationManifest":
                                projectDigest.BaseApplicationManifest = buildItem.Include;
                                break;
                           default:
                                log.Debug("Unhandled ItemGroup: " + buildItem.Name);
                                break;
                        }
                    }
                }
            }
        }
Example #14
0
        public static NPanday.Model.Pom.Model[] ConvertProjectsToPomModels(ProjectDigest[] projectDigests, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId, bool writePoms, string scmTag, List<Reference> missingReferences, List<string> nonPortableReferences)
        {
            try
            {
                string version = parent != null ? parent.version : null;

                List<NPanday.Model.Pom.Model> models = new List<NPanday.Model.Pom.Model>();
                foreach (ProjectDigest projectDigest in projectDigests)
                {
                    NPanday.Model.Pom.Model model = ConvertProjectToPomModel(projectDigest, mainPomFile, parent, groupId, writePoms, scmTag, missingReferences, nonPortableReferences);

                    models.Add(model);
                }
                return models.ToArray();
            }
            catch
            {
                throw;
            }
        }
Example #15
0
        // dependency sorter
        private static int CompareByDependency(ProjectDigest x, ProjectDigest y)
        {
            // Less than 0, x is less than y. (x is referring to y)
            // 0, x equals y. (not refering to each other)
            // Greater than 0, x is greater than y. (x is reffered by y)

            foreach (ProjectReference prjRef in y.ProjectReferences)
            {
                if (x.ProjectName.Equals(prjRef.Name))
                {
                    // Greater than 0, x is greater than y. (x is reffered by y)
                    return -1;
                }
            }

            foreach (ProjectReference prjRef in x.ProjectReferences)
            {
                if (y.ProjectName.Equals(prjRef.Name))
                {
                    // Less than 0, x is less than y. (x is referring to y)
                    return 1;
                }
            }
            // x equals y.
            return 0;
        }
 public static void VerifyTests(ref ProjectDigest[] projectDigests, ProjectStructureType structureType, string solutionFile, ref string groupId, ref string artifactId, ref string version)
 {
     VerifyUnitTestsForm verifyForm = new VerifyUnitTestsForm(projectDigests);
     verifyForm.ShowDialog();
 }
        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;
        }
Example #18
0
 public VerifyUnitTestsForm(ProjectDigest[] projectDigets)
 {
     this.projectDigets = projectDigets;
     InitializeComponent();
     FillCheckList();
 }
Example #19
0
        static bool IsProjectAbnormal(ProjectDigest[] projectDigests)
        {
            List<string> dirs = new List<string>();

            foreach (ProjectDigest prjDigest in projectDigests)
            {

                foreach (string dir in dirs)
                {
                    if(IsSameDirectory(prjDigest.FullDirectoryName, dir))
                    {
                        // this indecates that 2 or more projects has the same folder
                        return true;
                    }
                }

                dirs.Add(prjDigest.FullDirectoryName);
            }

            return false;
        }
Example #20
0
 /// <summary>
 /// Facade for Getting the Project Type. 
 /// calls NPanday.ProjectImporter.Validator.ProjectValidator.GetProjectStructureType(...)
 /// </summary>
 /// <param name="solutionFile">the full path of the *.sln (visual studio solution) file you want to import</param>
 /// <param name="projectDigests">Digested Projects</param>
 /// <returns></returns>
 public static ProjectStructureType GetProjectStructureType(string solutionFile, ProjectDigest[] projectDigests)
 {
     return ProjectValidator.GetProjectStructureType(solutionFile, projectDigests);
 }
 public override string[] ImportProjectType(ProjectDigest[] prjDigests, string solutionFile, string groupId, string artifactId, string version, string scmTag, bool writePom, List<Reference> missingReferences, List<string> nonPortableReferences)
 {
     return GenerateChildPoms(prjDigests, groupId, null, null, writePom, scmTag, missingReferences, nonPortableReferences);
 }
Example #22
0
        public static NPanday.Model.Pom.Model MakeProjectsParentPomModel(ProjectDigest[] projectDigests, string pomFileName, string groupId, string artifactId, string version, string scmTag, bool writePom)
        {
            string errorPrj = string.Empty;
            try
            {
                NPanday.Model.Pom.Model model = new NPanday.Model.Pom.Model();

                model.modelVersion = "4.0.0";
                model.packaging = "pom";
                model.groupId = groupId;
                model.artifactId = artifactId;
                model.version = version;
                model.name = string.Format("{0} : {1}", groupId, artifactId);
                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);
                }

                Uri repoUri;
                bool isValidUrl = true;
                try
                {
                    if (!scmTag.Equals(string.Empty))
                    {
                        repoUri = new Uri(scmTag);
                    }

                }
                catch(Exception)
                {
                    isValidUrl=false;
                    log.InfoFormat("SCM Tag was not added, because the url {0} was not accessible", scmTag);
                }

                if (!string.Empty.Equals(scmTag) && scmTag != null && isValidUrl)
                {
                    scmTag = scmTag.Trim();

                    Scm scmHolder = new Scm();
                    scmHolder.connection = string.Format("scm:svn:{0}",scmTag);
                    scmHolder.developerConnection = string.Format("scm:svn:{0}", scmTag); //why forcibly Subversion? (scm:hg for example). Need to add more fields to configure.
                    scmHolder.url = scmTag;
                    model.scm = scmHolder;
                }

                List<string> modules = new List<string>();
                foreach (ProjectDigest projectDigest in projectDigests)
                {
                    DirectoryInfo prjDir = new DirectoryInfo
                        (
                            projectDigest.ProjectType == VisualStudioProjectTypeEnum.Web_Site
                            ? projectDigest.FullFileName
                            : Path.GetDirectoryName(projectDigest.FullFileName)
                        );
                    DirectoryInfo pomDir = new DirectoryInfo(Path.GetDirectoryName(pomFileName));

                    string moduleDir = PomHelperUtility.GetRelativePath(pomDir, prjDir);
                    if (string.IsNullOrEmpty(moduleDir))
                    {
                        moduleDir = ".";
                        errorPrj += projectDigest.FullFileName;
                    }
                    modules.Add(moduleDir.Replace(@"\","/"));

                }

                modules.Sort();
                model.modules = modules.ToArray();

                if (writePom)
                {
                    PomHelperUtility.WriteModelToPom(new FileInfo(pomFileName), model);
                }
                return model;
            }
            catch (Exception e)
            {
                throw new Exception("Project Importer failed with project \""+ errorPrj
                                   + "\". Project directory structure may not be supported.");
            }
        }
Example #23
0
 public AzurePomConverter(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId)
     : base(projectDigest,mainPomFile,parent, groupId)
 {
 }
Example #24
0
 public static string[] ImportProjectType(ProjectStructureType structureType, ProjectDigest[] prjDigests, string solutionFile, string groupId, string artifactId, string version, string scmTag, List<Reference> missingReferences, List<string> nonPortableReferences)
 {
     return _importProject[structureType](prjDigests, solutionFile, groupId, artifactId, version, scmTag, true, missingReferences, nonPortableReferences);
 }
Example #25
0
        public static NPanday.Model.Pom.Model ConvertProjectToPomModel(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId, bool writePom, string scmTag, List<Reference> missingReferences, List<string> nonPortableReferences)
        {
            if (!__converterAlgorithms.ContainsKey(projectDigest.ProjectType))
            {
                throw new NotSupportedException("Unsupported project type: " + projectDigest.ProjectType);
            }
            else
               {
               // fudge the project type - though overall this would be better with "capabilities" or some filters instead
               if ((projectDigest.ProjectType & VisualStudioProjectTypeEnum.Web_Application) != 0 && projectDigest.UseMsDeploy)
               {
                   projectDigest.ProjectType |= VisualStudioProjectTypeEnum.WebDeploy2;
               }
               if (projectDigest.RoleType != null && projectDigest.RoleType.Equals("Worker", StringComparison.InvariantCultureIgnoreCase))
               {
                   projectDigest.ProjectType |= VisualStudioProjectTypeEnum.WindowsAzure_Worker;
               }

               IPomConverter converter = (IPomConverter)System.Activator.CreateInstance(
                   __converterAlgorithms[projectDigest.ProjectType],
                   projectDigest,
                   mainPomFile,
                   parent,
                   groupId);

               converter.ConvertProjectToPomModel(scmTag);

               missingReferences.AddRange(converter.GetMissingReferences());

               foreach (string s in converter.GetNonPortableReferences())
               {
                   if (!nonPortableReferences.Contains(s))
                       nonPortableReferences.Add(s);
               }

               return converter.Model;
               }
        }
 public abstract string[] ImportProjectType(ProjectDigest[] prjDigests, string solutionFile, string groupId, string artifactId, string version, string scmTag, bool writePom, List<Reference> missingReferences, List<string> nonPortableReferences);
Example #27
0
        protected Dependency CreateInterProjectDependency(string name, ProjectDigest digest)
        {
            Dependency interDependency = new Dependency();

            interDependency.artifactId = name;
            interDependency.groupId = !string.IsNullOrEmpty(groupId) ? groupId : name;
            interDependency.version = string.IsNullOrEmpty(version) ? "1.0-SNAPSHOT" : version;
            interDependency.type = "dotnet-library";

            if (digest != null
                && !string.IsNullOrEmpty(digest.OutputType))
            {
                string type = digest.OutputType.ToLower();
                if (npandayTypeMap.ContainsKey(type))
                    type = npandayTypeMap[type];
                interDependency.type = type;
            }
            return interDependency;
        }
        static bool IsProjectHavingANewImportedProject(ProjectDigest[] projectDigests)
        {
            foreach (ProjectDigest projectDigest in projectDigests)
            {
                if (projectDigest == null)
                {
                    return true;
                }

            }

            return false;
        }