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);
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
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);
        }
Esempio n. 3
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)
        {
            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());

                return(converter.Model);
            }
        }
        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 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);
        }
Esempio n. 6
0
        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>();

            // 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;
            }
        }
Esempio n. 7
0
 public NormalPomConverter(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId)
     : base(projectDigest, mainPomFile, parent, groupId)
 {
 }
Esempio n. 8
0
        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());
        }
        private static void DigestBuildProperties(Project project, ProjectDigest projectDigest)
        {
            foreach (BuildPropertyGroup buildPropertyGroup in project.PropertyGroups)
            {
                foreach (BuildProperty buildProperty in buildPropertyGroup)
                {
                    if (!buildProperty.IsImported)
                    {
                        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 ("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 ("TargetFrameworkVersion".Equals(buildProperty.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            // changed the version to the more specific version
                            string frameworkVersion = buildProperty.Value.Substring(1);

                            if ("2.0".Equals(buildProperty.Value.Substring(1)))
                            {
                                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))
                            {
                                try
                                {
                                    VisualStudioProjectTypeEnum t = VisualStudioProjectType.GetVisualStudioProjectType(buildProperty.Value);
                                    projectDigest.ProjectType = t;
                                }
                                catch
                                {
                                    throw;
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Unhandled Property:" + buildProperty.Name);
                        }
                    }
                }
            }
        }
        public ProjectDigest DigestProject(Dictionary <string, object> projectMap)
        {
            Project project = (Project)projectMap["Project"];


            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);

            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 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":
                            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))
                            {
                                if (buildItem.Include.Contains(","))
                                {
                                    // complete name
                                    reference.SetAssemblyInfoValues(buildItem.Include);
                                }
                                else if (!rsp.IsRspIncluded(buildItem.Include, projectDigest.Language))
                                {
                                    // simple name needs to be resolved
                                    List <string> refs = GacUtility.GetInstance().GetAssemblyInfo(buildItem.Include, null, null);
                                    if (refs.Count == 0)
                                    {
                                        Console.WriteLine("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
                                                Console.WriteLine("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]);
                                    }
                                }
                            }
                            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");

                            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:
                            Console.WriteLine("Unhandled ItemGroup: " + buildItem.Name);
                            break;
                        }
                    }
                }
            }
        }
        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);
            }
        }
Esempio n. 13
0
        public ProjectDigest DigestProject(Dictionary <string, object> projectMap)
        {
            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();
            }

            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);
        }
Esempio n. 14
0
 public WebWithVbOrCsProjectFilePomConverter(ProjectDigest projectDigest, string mainPomFile, NPanday.Model.Pom.Model parent, string groupId)
     : base(projectDigest, mainPomFile, parent, groupId)
 {
 }
Esempio n. 15
0
        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());
        }