/// <summary>
        ///   Creates <c>ProjectInfo</c> for setup project provided.
        /// </summary>
        /// <param name="project">
        ///   Project examined.
        /// </param>
        /// <param name="projectTypeInfo">
        /// </param>
        /// <returns>
        ///   <c>ProjectInfo</c> for the project provided.
        /// </returns>
        private ProjectInfo GetSetupInfo(Project project, string parentUiPath, ProjectTypeInfo projectTypeInfo, int level)
        {
            Debug.Assert(project != null);
            Debug.Assert(projectTypeInfo != null && (projectTypeInfo.ProjectType == ProjectType.SetupProject || projectTypeInfo.ProjectType == ProjectType.InstallShieldLEProject));
            string directoryName        = Path.GetDirectoryName(project.FileName);
            string versionFileExtension = Path.GetExtension(projectTypeInfo.AssemblyInfoFilename);
            string setupFilename        = Path.ChangeExtension(Path.GetFileName(project.UniqueName), versionFileExtension);
            string filename             = Path.Combine(directoryName, setupFilename);

            Debug.Assert(File.Exists(filename));
            VersionStream versionStream = null;

            switch (projectTypeInfo.ProjectType)
            {
            case ProjectType.SetupProject:
                versionStream = new SetupVersionStream(filename);
                break;

            case ProjectType.InstallShieldLEProject:
                versionStream = new InstallShieldLEVersionStream(filename);
                break;

            default:
                Debug.Assert(false);
                break;
            }
            Debug.Assert(versionStream != null);
            AssemblyVersions setupVersion = versionStream.GetVersions();

            // setup projects are always at solution root
            return(new ProjectInfo(project.Name, project.FullName, AppendBranchToPath(parentUiPath, project.Name), projectTypeInfo, false, level, setupVersion, new VersionStream[] { versionStream }));
        }
Example #2
0
 /// <summary>
 ///   Initializes <c>ProjectInfo</c> object.
 /// </summary>
 /// <param name="projectName">
 ///   Name of the project.
 /// </param>
 /// <param name="projectFullName">
 ///   Project full name.
 /// </param>
 /// <param name="projectTypeInfo">
 ///   Type of the project.
 /// </param>
 /// <param name="level">
 ///   Indentation level.
 /// </param>
 public ProjectInfo(string projectName, string projectFullName, string uiPath, ProjectTypeInfo projectTypeInfo, int level) : this()
 {
     ProjectName     = projectName;
     ProjectRoot     = Path.GetDirectoryName(projectFullName);
     FullName        = projectFullName;
     UIPath          = uiPath;
     ProjectTypeInfo = projectTypeInfo;
     m_level         = level;
 }
        /// <summary>
        ///   Browses the solution for all projects, creates corresponding
        ///   <c>ProjectInfo</c> and and adds them to <c>m_projects</c> list.
        /// </summary>
        private void LoadProjectsInfo()
        {
            Debug.Assert(m_devEnvApplicationObject != null && m_devEnvApplicationObject.Solution != null);
            Debug.Assert(m_allProjects != null);
            m_allProjects.Clear();
            int level = 0;

            foreach (Project project in m_devEnvApplicationObject.Solution.Projects)
            {
                try
                {
                    ProjectTypeInfo projectTypeInfo = ProjectTypeInfo.ProjectTypeInfos[project.Kind];
                    if (projectTypeInfo != null)
                    {
                        Debug.Assert(projectTypeInfo != null);
                        // setup projects are treated differently since the version is stored inside project file!
                        if (projectTypeInfo == ProjectTypeInfo.SetupProject || projectTypeInfo == ProjectTypeInfo.InstallShieldLEProject)
                        {
                            m_allProjects.Add(GetSetupInfo(project, "", projectTypeInfo, 0));
                        }
                        else if (projectTypeInfo == ProjectTypeInfo.EnterpriseProject)
                        {
                            // it is enterprise template project with subprojects
                            ProjectInfo enterpriseTemplateProjectInfo = new ProjectInfo(project.Name, project.FullName, project.Name, projectTypeInfo, level);
                            RecurseSubProjectTree(project.ProjectItems, enterpriseTemplateProjectInfo, level);
                            m_allProjects.Add(enterpriseTemplateProjectInfo);
                        }
                        else if (projectTypeInfo == ProjectTypeInfo.SolutionFolder)
                        {
                            ProjectInfo solutionFolder = new ProjectInfo(project.Name, project.Name, project.Name, projectTypeInfo, level);
                            RecurseSubProjectTree(project.ProjectItems, solutionFolder, level);
                            m_allProjects.Add(solutionFolder);
                        }
                        else
                        {
                            m_allProjects.Add(GetProjectInfo(project, "", projectTypeInfo, level));
                        }
                    }
                    else
                    {
                        Trace.WriteLine(string.Format("Not supported project kind: {0}", project.Kind));
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
#if DEBUG
                    ExceptionForm.Show(new WindowAdapter(m_devEnvApplicationObject.MainWindow.HWnd), e, "VCB Error");
#endif
                }
            }
        }
        /// <summary>
        ///   Creates <c>ProjectInfo</c> for project provided.
        /// </summary>
        /// <param name="project">
        ///   Project examined.
        /// </param>
        /// <param name="projectTypeInfo">
        ///   Project type info for the project.
        /// </param>
        /// <returns>
        ///   <c>ProjectInfo</c> for the project provided.
        /// </returns>
        private ProjectInfo GetProjectInfo(Project project, string parentUiPath, ProjectTypeInfo projectTypeInfo, int level)
        {
            if (!projectTypeInfo.IsVersionable)
            {
                return(new ProjectInfo(project.Name, project.FullName, AppendBranchToPath(parentUiPath, project.Name), projectTypeInfo, level));
            }
            // array of version streams that will be provided to ProjectInfo constructor
            ArrayList versionStreams = new ArrayList();
            // AssemblyVersions used to find the largest one
            AssemblyVersions assemblyVersions = AssemblyVersions.Empty;

            // for a VC++ project search for resource file (which may contain version) if configured so
            if (projectTypeInfo == ProjectTypeInfo.VCppProject && m_numberingOptions.IncludeVCppResourceFiles)
            {
                string[] resourceFilenames = GetProjectVersionFile(project, "*.rc");
                // if VC++ project contains both AssemblyInfo file and resource
                // file with version, compare them and get the larger value
                foreach (string resourceFilename in resourceFilenames)
                {
                    VersionStream    resourceFileStream = new ResourceFileStream(resourceFilename);
                    AssemblyVersions resourceVersion    = resourceFileStream.GetVersions();
                    versionStreams.Add(resourceFileStream);
                    assemblyVersions = AssemblyVersions.Max(assemblyVersions, resourceVersion);
                }
            }
            string[] assemblyInfoFilenames = GetProjectVersionFile(project, projectTypeInfo.AssemblyInfoFilename);
            Debug.Assert(assemblyInfoFilenames.Length <= 1);
            if (assemblyInfoFilenames.Length > 0)
            {
                VersionStream    assemblyInfoStream   = new AssemblyInfoStream(assemblyInfoFilenames[0]);
                AssemblyVersions assemblyInfoVersions = assemblyInfoStream.GetVersions();
                versionStreams.Add(assemblyInfoStream);
                if (assemblyVersions == AssemblyVersions.Empty)
                {
                    assemblyVersions = assemblyInfoVersions;
                }
                else
                {
                    assemblyVersions = AssemblyVersions.Max(assemblyVersions, assemblyInfoVersions);
                }
            }
            VersionStream[] vs = (VersionStream[])versionStreams.ToArray(typeof(VersionStream));
            bool            isProjectModified = IsProjectModified(project, vs);

            return(new ProjectInfo(project.Name, project.FullName, AppendBranchToPath(parentUiPath, project.Name), projectTypeInfo, isProjectModified, level, assemblyVersions, vs));
        }
 /// <summary>
 ///   Recurses sub project tree (e.g. for Enterprise template projects)
 ///   searching for the largest version.
 /// </summary>
 /// <param name="projectItems">
 ///   Collection of <c>ProjectItems</c> to recurse.
 /// </param>
 private void RecurseSubProjectTree(ProjectItems parentProjectItems, ProjectInfo parentProjectInfo, int level)
 {
     level++;
     Debug.Assert(parentProjectItems != null);
     Debug.Assert(parentProjectInfo != null);
     try
     {
         foreach (ProjectItem projectItem in parentProjectItems)
         {
             try
             {
                 Project subProject = projectItem.SubProject;
                 if (subProject != null)
                 {
                     ProjectTypeInfo subProjectTypeInfo = ProjectTypeInfo.ProjectTypeInfos[subProject.Kind];
                     if (subProjectTypeInfo == ProjectTypeInfo.EnterpriseProject || subProjectTypeInfo == ProjectTypeInfo.SolutionFolder)
                     {
                         ProjectInfo subProjectInfo = new ProjectInfo(subProject.Name, subProject.Name, AppendBranchToPath(parentProjectInfo.UIPath, subProject.Name), subProjectTypeInfo, level);
                         RecurseSubProjectTree(subProject.ProjectItems, subProjectInfo, level);
                         parentProjectInfo.SubProjects.Add(subProjectInfo);
                     }
                     else if (subProjectTypeInfo == ProjectTypeInfo.SetupProject)
                     {
                         ProjectInfo pi = GetSetupInfo(subProject, parentProjectInfo.UIPath, subProjectTypeInfo, level);
                         Debug.Assert(pi != null);
                         Debug.Assert(m_allProjects != null);
                         parentProjectInfo.SubProjects.Add(pi);
                     }
                     else if (subProjectTypeInfo != null)
                     {
                         ProjectInfo pi = GetProjectInfo(subProject, parentProjectInfo.UIPath, subProjectTypeInfo, level);
                         Debug.Assert(pi != null);
                         Debug.Assert(m_allProjects != null);
                         parentProjectInfo.SubProjects.Add(pi);
                     }
                 }
                 else
                 {
                     // folders do not have subprojects but only project items
                     ProjectTypeInfo projectTypeInfo = ProjectTypeInfo.ProjectTypeInfos[projectItem.Kind];
                     if (projectTypeInfo == ProjectTypeInfo.VirtualFolder)
                     {
                         ProjectInfo subProjectInfo = new ProjectInfo(projectItem.Name, projectItem.Name, AppendBranchToPath(parentProjectInfo.UIPath, projectItem.Name), projectTypeInfo, level);
                         RecurseSubProjectTree(projectItem.ProjectItems, subProjectInfo, level);
                         if (subProjectInfo.SubProjects.Count > 0)
                         {
                             parentProjectInfo.SubProjects.Add(subProjectInfo);
                         }
                     }
                 }
             }
             catch (NotImplementedException e)
             {
                 Debug.WriteLine(e.ToString());
             }
         }
     }
     catch (Exception e)
     {
         ExceptionForm.Show(new WindowAdapter(m_devEnvApplicationObject.MainWindow.HWnd), e, "Browsing Solution Error");
     }
 }
Example #6
0
 /// <summary>
 ///   Initializes <c>ProjectInfo</c> object.
 /// </summary>
 /// <param name="project">
 ///   Project for which object is created.
 /// </param>
 /// <param name="projectTypeInfo">
 ///   ProjectTypeInfo to initialize with.
 /// </param>
 /// <param name="version">
 ///   <c>ProjectVersion</c>.
 /// </param>
 /// <param name="assemblyInfoItem">
 ///   <c>AssemblyInfo</c>
 /// </param>
 /// <param name="numberingOptions">
 ///   Numbering options.
 /// </param>
 public ProjectInfo(string projectName, string projectFullName, string uiPath, ProjectTypeInfo projectTypeInfo, bool modified, int level, AssemblyVersions assemblyVersions, VersionStream[] versionStreams) : this(projectName, projectFullName, uiPath, projectTypeInfo, level)
 {
     CurrentAssemblyVersions = assemblyVersions;
     m_versionStreams        = new ArrayList(versionStreams);
     Modified = modified;
 }
Example #7
0
 public ProjectInfo(string projectName, string projectFullName, ProjectTypeInfo projectTypeInfo, bool modified, int level, AssemblyVersions assemblyVersions, VersionStream[] versionStreams) : this(projectName, projectFullName, "", projectTypeInfo, modified, level, assemblyVersions, versionStreams)
 {
 }
Example #8
0
 public ProjectInfo(string projectName, string projectFullName, ProjectTypeInfo projectTypeInfo, int level) : this(projectName, projectFullName, "", projectTypeInfo, level)
 {
 }