コード例 #1
0
 public int OnQueryRenameFiles(IVsProject project, int filesLength, string[] oldNames, string[] newNames,
                               VSQUERYRENAMEFILEFLAGS[] rgFlags, VSQUERYRENAMEFILERESULTS[] pSummaryResult,
                               VSQUERYRENAMEFILERESULTS[] rgResults)
 {
     try
     {
         IceBuilderProjectType projectType = DTEUtil.IsIceBuilderNuGetInstalled(project);
         if (projectType != IceBuilderProjectType.None)
         {
             for (int i = 0; i < filesLength; ++i)
             {
                 if (ProjectUtil.IsSliceFileName(newNames[i]))
                 {
                     if (!ProjectUtil.CheckGenerateFileIsValid(project, projectType, newNames[i]))
                     {
                         rgResults[i] = VSQUERYRENAMEFILERESULTS.VSQUERYRENAMEFILERESULTS_RenameNotOK;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
     }
     return(0);
 }
コード例 #2
0
        //
        // Set Ice Home and force projects to re evaluate changes in the imported project
        //
        public static void SetIceHome(List <IVsProject> projects, string iceHome, string iceVersion, string iceIntVersion, string iceVersionMM)
        {
            foreach (IVsProject p in projects)
            {
                if (DTEUtil.IsIceBuilderEnabled(p) != IceBuilderProjectType.None)
                {
                    Microsoft.Build.Evaluation.Project project = LoadedProject(ProjectUtil.GetProjectFullPath(p), DTEUtil.IsCppProject(p), true);
                    ResolvedImport import = project.Imports.FirstOrDefault(i => i.ImportedProject.FullPath.EndsWith("IceBuilder.Common.props"));

                    if (import.ImportedProject != null)
                    {
                        ProjectPropertyGroupElement group = import.ImportedProject.PropertyGroups.FirstOrDefault(
                            g => g.Label.Equals("IceHome", StringComparison.CurrentCultureIgnoreCase));
                        if (group != null)
                        {
                            group.SetProperty(Package.IceHomeValue, iceHome);
                            group.SetProperty(Package.IceVersionValue, iceVersion);
                            group.SetProperty(Package.IceIntVersionValue, iceIntVersion);
                            group.SetProperty(Package.IceVersionMMValue, iceVersionMM);
                            project.ReevaluateIfNecessary();
                        }
                    }
                }
            }
        }
コード例 #3
0
        public void InitializeProjects(List <IVsProject> upgradeProjects)
        {
            ProjectConverter.TryUpgrade(upgradeProjects);

            List <IVsProject> projects = DTEUtil.GetProjects();

            List <IVsProject> sliceProjects = new List <IVsProject>();

            foreach (IVsProject project in projects)
            {
                IceBuilderProjectType projectType = DTEUtil.IsIceBuilderEnabled(project);

                if (projectType != IceBuilderProjectType.None)
                {
                    if (projectType == IceBuilderProjectType.CppProjectType)
                    {
                        VCUtil.SetupSliceFilter(DTEUtil.GetProject(project as IVsHierarchy));
                    }
                    if (AutoBuilding)
                    {
                        sliceProjects.Add(project);
                    }
                    else
                    {
                        FileTracker.Add(project, projectType);
                    }
                }
            }

            if (AutoBuilding)
            {
                QueueProjectsForBuilding(sliceProjects);
            }
        }
コード例 #4
0
        public static void TryUpgrade(List <IVsProject> projects)
        {
            string baseDir = string.Empty;

            if (!string.IsNullOrEmpty(Package.Instance.DTE2.Solution.FullName))
            {
                baseDir = Path.GetDirectoryName(Package.Instance.DTE2.Solution.FullName);
            }
            Dictionary <string, IVsProject> upgradeProjects = new Dictionary <string, IVsProject>();

            foreach (IVsProject project in projects)
            {
                if (DTEUtil.IsCppProject(project) || DTEUtil.IsCSharpProject(project))
                {
                    string fullName = ProjectUtil.GetProjectFullPath(project);
                    if (new OldConfiguration().Load(MSBuildUtils.LoadedProject(fullName, DTEUtil.IsCppProject(project), true), false))
                    {
                        upgradeProjects.Add(FileUtil.RelativePath(baseDir, fullName), project);
                    }
                }
            }

            if (upgradeProjects.Count > 0)
            {
                UpgradeDialog dialog = new UpgradeDialog();
                dialog.StartPosition = FormStartPosition.CenterParent;
                dialog.Projects      = upgradeProjects;
                dialog.ShowDialog();
            }
        }
コード例 #5
0
 private void addIceBuilder_BeforeQueryStatus(object sender, EventArgs e)
 {
     try
     {
         OleMenuCommand command = sender as OleMenuCommand;
         if (command != null)
         {
             IVsProject p = DTEUtil.GetSelectedProject();
             if (p != null)
             {
                 if (DTEUtil.IsCppProject(p) || DTEUtil.IsCSharpProject(p))
                 {
                     command.Enabled = !MSBuildUtils.IsIceBuilderEnabled(MSBuildUtils.LoadedProject(
                                                                             ProjectUtil.GetProjectFullPath(p), DTEUtil.IsCppProject(p), true));
                 }
                 else
                 {
                     command.Enabled = false;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
         throw;
     }
 }
        private EnvDTE.ProjectItem GetProjectItemFromDocumentCookie(uint cookie)
        {
            uint         pgrfRDTFlags;
            uint         pdwReadLocks;
            uint         pdwEditLocks;
            string       pbstrMkDocument;
            IVsHierarchy ppHier;
            uint         pitemid;
            IntPtr       ppunkDocData;

            try
            {
                if (RunningDocumentTable.GetDocumentInfo(
                        cookie,
                        out pgrfRDTFlags,
                        out pdwReadLocks,
                        out pdwEditLocks,
                        out pbstrMkDocument,
                        out ppHier,
                        out pitemid,
                        out ppunkDocData) == VSConstants.S_OK)
                {
                    return(DTEUtil.GetProjectItem(ppHier, pitemid));
                }
            }
            catch (Exception ex)
            {
                Package.UnexpectedExceptionWarning(ex);
                throw;
            }
            return(null);
        }
コード例 #7
0
 public void AddIceBuilderToProject(EnvDTE.Project p)
 {
     Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(p.FullName);
     if (MSBuildUtils.AddIceBuilderToProject(project))
     {
         if (DTEUtil.IsCppProject(p))
         {
             VCUtil.SetupSliceFilter(p);
         }
         else
         {
             String includeDirectories = ProjectUtil.GetProperty(p, PropertyNames.IncludeDirectories);
             if (String.IsNullOrEmpty(includeDirectories))
             {
                 ProjectUtil.SetProperty(p, PropertyNames.IncludeDirectories, @"$(IceHome)\slice");
             }
             else if (includeDirectories.IndexOf(@"$(IceHome)\slice") == -1)
             {
                 ProjectUtil.SetProperty(p, PropertyNames.IncludeDirectories,
                                         String.Format(@"$(IceHome)\slice;{0}", includeDirectories));
             }
             ProjectUtil.AddAssemblyReference(p, "Ice");
         }
         p.Save();
         IVsHierarchy hier        = DTEUtil.GetIVsHierarchy(p);
         Guid         projectGUID = Guid.Empty;
         IVsSolution.GetGuidOfProject(hier, out projectGUID);
         IVsSolution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, hier, 0);
         project.Save();
         IVsSolution4.ReloadProject(ref projectGUID);
     }
 }
 public int OnAfterRenameFiles(int projectsLength, int filesLength, IVsProject[] projects, int[] indices,
                               string[] oldNames, string[] newNames, VSRENAMEFILEFLAGS[] rgFlags)
 {
     try
     {
         for (int i = 0; i < projectsLength; ++i)
         {
             EnvDTE.Project project = DTEUtil.GetProject(projects[i] as IVsHierarchy);
             if (DTEUtil.IsIceBuilderEnabled(project))
             {
                 int j = indices[i];
                 int k = i < (projectsLength - 1) ? indices[i + 1] : filesLength;
                 for (; j < k; ++j)
                 {
                     ProjectUtil.DeleteItems(project, ProjectUtil.GetGeneratedFiles(project, oldNames[j]));
                     if (ProjectUtil.IsSliceFileName(newNames[j]))
                     {
                         ProjectUtil.SetupGenerated(project, newNames[j]);
                     }
                 }
                 Package.Instance.FileTracker.Reap(project);
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
         throw;
     }
     return(0);
 }
コード例 #9
0
 public int OnAfterRenameFiles(int projectsLength, int filesLength, IVsProject[] projects, int[] indices,
                               string[] oldNames, string[] newNames, VSRENAMEFILEFLAGS[] rgFlags)
 {
     try
     {
         for (int i = 0; i < projectsLength; ++i)
         {
             IVsProject            project     = projects[i];
             IceBuilderProjectType projectType = DTEUtil.IsIceBuilderNuGetInstalled(project);
             if (projectType != IceBuilderProjectType.None)
             {
                 int j = indices[i];
                 int k = i < (projectsLength - 1) ? indices[i + 1] : filesLength;
                 for (; j < k; ++j)
                 {
                     string oldPath = oldNames[i];
                     string newPath = newNames[j];
                     if (ProjectUtil.IsSliceFileName(oldPath) || ProjectUtil.IsSliceFileName(newPath))
                     {
                         ProjectUtil.SetupGenerated(project, projectType);
                         break;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
     }
     return(0);
 }
 public int OnQueryRenameFiles(IVsProject ivsProject, int filesLength, string[] oldNames, string[] newNames,
                               VSQUERYRENAMEFILEFLAGS[] rgFlags, VSQUERYRENAMEFILERESULTS[] pSummaryResult,
                               VSQUERYRENAMEFILERESULTS[] rgResults)
 {
     try
     {
         EnvDTE.Project project = DTEUtil.GetProject(ivsProject as IVsHierarchy);
         if (DTEUtil.IsIceBuilderEnabled(project))
         {
             for (int i = 0; i < filesLength; ++i)
             {
                 if (Path.GetExtension(oldNames[i]).Equals(".ice") &&
                     Path.GetExtension(newNames[i]).Equals(".ice"))
                 {
                     if (!ProjectUtil.CheckGenerateFileIsValid(project, newNames[i]))
                     {
                         rgResults[i] = VSQUERYRENAMEFILERESULTS.VSQUERYRENAMEFILERESULTS_RenameNotOK;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
         throw;
     }
     return(0);
 }
コード例 #11
0
 public int OnQueryAddFiles(IVsProject project, int length, string[] files,
                            VSQUERYADDFILEFLAGS[] rgFlags, VSQUERYADDFILERESULTS[] pSummaryResult,
                            VSQUERYADDFILERESULTS[] rgResults)
 {
     try
     {
         if (files.Any(f => ProjectUtil.IsSliceFileName(f)))
         {
             IceBuilderProjectType projectType = DTEUtil.IsIceBuilderNuGetInstalled(project);
             if (projectType != IceBuilderProjectType.None)
             {
                 for (int i = 0; i < length; ++i)
                 {
                     if (ProjectUtil.IsSliceFileName(files[i]))
                     {
                         if (!ProjectUtil.CheckGenerateFileIsValid(project, projectType, files[i]))
                         {
                             pSummaryResult[i] = VSQUERYADDFILERESULTS.VSQUERYADDFILERESULTS_AddNotOK;
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
     }
     return(0);
 }
コード例 #12
0
        public static void SetupGenerated(EnvDTE.Project project, String file)
        {
            List <String> generated = GetGeneratedFiles(project, file);

            foreach (String generatedFile in generated)
            {
                if (!Directory.Exists(Path.GetDirectoryName(generatedFile)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(generatedFile));
                }

                if (!File.Exists(generatedFile))
                {
                    File.Create(generatedFile).Dispose();
                }

                EnvDTE.ProjectItem item = FindProjectItem(generatedFile, project.ProjectItems);
                if (item == null)
                {
                    if (DTEUtil.IsCppProject(project))
                    {
                        String filter = KnownHeaderExtension.Contains(
                            Path.GetExtension(generatedFile)) ? "Header Files" : "Source Files";

                        Package.Instance.VCUtil.AddToFilter(project, filter, generatedFile);
                    }
                    else
                    {
                        project.ProjectItems.AddFromFile(generatedFile);
                    }
                }
            }
            Package.Instance.FileTracker.Add(project, file, generated);
        }
コード例 #13
0
 private void removeIceBuilder_BeforeQueryStatus(object sender, EventArgs e)
 {
     try
     {
         OleMenuCommand command = sender as OleMenuCommand;
         if (command != null)
         {
             EnvDTE.Project p = DTEUtil.GetSelectedProject();
             if (p != null)
             {
                 if (DTEUtil.IsCppProject(p) || DTEUtil.IsCSharpProject(p))
                 {
                     command.Enabled = MSBuildUtils.IsIceBuilderEnabeld(MSBuildUtils.LoadedProject(p.FullName));
                 }
                 else
                 {
                     command.Enabled = false;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
         throw;
     }
 }
コード例 #14
0
        public static bool AddProjectFlavorIfNotExists(Microsoft.Build.Evaluation.Project project, string flavor)
        {
            ProjectPropertyElement property = project.Xml.Properties.FirstOrDefault(
                p => p.Name.Equals("ProjectTypeGuids", StringComparison.CurrentCultureIgnoreCase));

            if (property != null)
            {
                if (property.Value.IndexOf(flavor) == -1)
                {
                    DTEUtil.EnsureFileIsCheckout(project.FullPath);
                    if (string.IsNullOrEmpty(property.Value))
                    {
                        property.Value = string.Format("{0};{1}", flavor, CSharpProjectGUI);
                    }
                    else
                    {
                        property.Value = string.Format("{0};{1}", flavor, property.Value);
                    }
                    return(true); //ProjectTypeGuids updated
                }
                else
                {
                    return(false); //ProjectTypeGuids already has this flavor
                }
            }

            // ProjectTypeGuids not present
            DTEUtil.EnsureFileIsCheckout(project.FullPath);
            project.Xml.AddProperty("ProjectTypeGuids", string.Format("{0};{1}", flavor, CSharpProjectGUI));
            return(true);
        }
コード例 #15
0
        public static void SetupGenerated(IVsProject project, EnvDTE.Configuration configuration, String filter, List <string> files, bool generatedFilesPerConfiguration)
        {
            List <string> missing = new List <string>();

            foreach (String file in files)
            {
                if (!Directory.Exists(Path.GetDirectoryName(file)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(file));
                }

                if (!File.Exists(file))
                {
                    File.Create(file).Dispose();
                }

                int  found;
                uint id;
                VSDOCUMENTPRIORITY[] priority = new VSDOCUMENTPRIORITY[1];
                project.IsDocumentInProject(file, out found, priority, out id);
                if (found == 0)
                {
                    missing.Add(file);
                }
            }

            Package.Instance.VCUtil.AddGeneratedFiles(DTEUtil.GetProject(project as IVsHierarchy), configuration, filter, missing, generatedFilesPerConfiguration);
        }
コード例 #16
0
 public int OnAfterRemoveFiles(int projectsLength, int filesLength, IVsProject[] projects, int[] indices,
                               string[] names, VSREMOVEFILEFLAGS[] rgFlags)
 {
     try
     {
         for (int i = 0; i < projectsLength; ++i)
         {
             IVsProject            project     = projects[i];
             IceBuilderProjectType projectType = DTEUtil.IsIceBuilderEnabled(project);
             if (projectType != IceBuilderProjectType.None)
             {
                 int j = indices[i];
                 int k = i < (projectsLength - 1) ? indices[i + 1] : filesLength;
                 for (; j < k; ++j)
                 {
                     string path = names[i];
                     if (ProjectUtil.IsSliceFileName(path))
                     {
                         ProjectUtil.SetupGenerated(project, projectType);
                         break;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
         throw;
     }
     return(0);
 }
 public int OnQueryAddFiles(IVsProject p, int length, string[] files,
                            VSQUERYADDFILEFLAGS[] rgFlags, VSQUERYADDFILERESULTS[] pSummaryResult,
                            VSQUERYADDFILERESULTS[] rgResults)
 {
     try
     {
         EnvDTE.Project project = DTEUtil.GetProject(p as IVsHierarchy);
         if (DTEUtil.IsIceBuilderEnabled(project))
         {
             for (int i = 0; i < length; ++i)
             {
                 String path = files[i];
                 if (Path.GetExtension(path).Equals(".ice"))
                 {
                     if (!ProjectUtil.CheckGenerateFileIsValid(project, path))
                     {
                         pSummaryResult[i] = VSQUERYADDFILERESULTS.VSQUERYADDFILERESULTS_AddNotOK;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
         throw;
     }
     return(0);
 }
        public int OnAfterAddFilesEx(int projectsLength, int filesLength, IVsProject[] projects, int[] indices,
                                     string[] paths, VSADDFILEFLAGS[] rgFlags)
        {
            try
            {
                for (int i = 0; i < projectsLength; ++i)
                {
                    EnvDTE.Project project = DTEUtil.GetProject(projects[i] as IVsHierarchy);
                    if (DTEUtil.IsIceBuilderEnabled(project))
                    {
                        int j = indices[i];
                        int k = i < (projectsLength - 1) ? indices[i + 1] : filesLength;

                        for (; j < k; ++j)
                        {
                            if (ProjectUtil.IsSliceFileName(paths[j]))
                            {
                                ProjectUtil.SetupGenerated(project, paths[j]);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Package.UnexpectedExceptionWarning(ex);
                throw;
            }
            return(0);
        }
コード例 #19
0
        CheckGenerateFileIsValid(IVsProject project, IceBuilderProjectType projectType, string path)
        {
            if (projectType == IceBuilderProjectType.CsharpProjectType)
            {
                string outputDir       = GetOutputDir(project, false, true);
                string generatedSource = GetCSharpGeneratedItemPath(Path.GetFileName(path));
                if (File.Exists(generatedSource))
                {
                    const string message =
                        "A file named '{0}' already exists.\nIf you want to add '{1}' first remove '{0}'.";

                    UIUtil.ShowErrorDialog("Ice Builder",
                                           string.Format(message,
                                                         GetPathRelativeToProject(project, generatedSource),
                                                         GetPathRelativeToProject(project, path)));
                    return(false);
                }
            }
            else if (projectType == IceBuilderProjectType.CppProjectType)
            {
                string source = GetCppGeneratedSourceItemPath(project, path);
                string header = GetCppGeneratedHeaderItemPath(project, path);

                EnvDTE.Project p = DTEUtil.GetProject(project as IVsHierarchy);

                foreach (EnvDTE.Configuration config in p.ConfigurationManager)
                {
                    string outputDir = Package.Instance.VCUtil.Evaluate(config, "$(IceBuilderOutputDir)");
                    outputDir = Path.GetFullPath(Path.Combine(GetProjectBaseDirectory(project), outputDir));
                    string headerOutputDir = Package.Instance.VCUtil.Evaluate(config, "$(IceBuilderHeaderOutputDir)");
                    if (string.IsNullOrEmpty(headerOutputDir))
                    {
                        headerOutputDir = outputDir;
                    }
                    else
                    {
                        headerOutputDir = Path.GetFullPath(Path.Combine(GetProjectBaseDirectory(project), headerOutputDir));
                    }
                    string generatedSource = Path.GetFullPath(Path.Combine(outputDir, source));
                    string generatedHeader = Path.GetFullPath(Path.Combine(headerOutputDir, header));

                    if (File.Exists(generatedSource) || File.Exists(generatedHeader))
                    {
                        const string message =
                            "A file named '{0}' or '{1}' already exists.\nIf you want to add '{2}' first remove '{0}' and '{1}'.";

                        UIUtil.ShowErrorDialog("Ice Builder",
                                               string.Format(message,
                                                             GetPathRelativeToProject(project, generatedSource),
                                                             GetPathRelativeToProject(project, generatedHeader),
                                                             GetPathRelativeToProject(project, path)));
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #20
0
        private void RemoveIceBuilderFromProject(IVsProject p)
        {
            String path = ProjectUtil.GetProjectFullPath(p);

            foreach (IVsProject p1 in _buildProjects)
            {
                if (path.Equals(ProjectUtil.GetProjectFullPath(p1)))
                {
                    _buildProjects.Remove(p1);
                    break;
                }
            }

            ProjectUtil.DeleteItems(
                ProjectUtil.GetGeneratedFiles(p).Aggregate(
                    new List <String>(),
                    (items, kv) =>
            {
                items.AddRange(kv.Value);
                return(items);
            }));

            if (DTEUtil.IsCSharpProject(p))
            {
                Directory.GetFiles(GetAssembliesDir(GetIceHome()), "*.dll")
                .ToList()
                .ForEach(item =>
                {
                    String name = Path.GetFileNameWithoutExtension(item);
                    if (ProjectUtil.HasAssemblyReference(DTEUtil.GetProject(p as IVsHierarchy), name))
                    {
                        ProjectUtil.RemoveAssemblyReference(DTEUtil.GetProject(p as IVsHierarchy), name);
                    }
                });
            }

            Microsoft.Build.Evaluation.Project project = MSBuildUtils.LoadedProject(path, DTEUtil.IsCppProject(p), true);
            MSBuildUtils.RemoveIceBuilderFromProject(project);
            ProjectUtil.SaveProject(p);

            Guid         projectGUID = Guid.Empty;
            IVsHierarchy hier        = p as IVsHierarchy;

            IVsSolution.GetGuidOfProject(hier, out projectGUID);
            IVsSolution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, hier, 0);
            project.Save();
            try
            {
                ProjectCollection.GlobalProjectCollection.UnloadProject(project);
            }
            catch (System.Exception)
            {
                //expected if the project is not in the global project collection
            }
            IVsSolution4.ReloadProject(ref projectGUID);
        }
コード例 #21
0
        private void PackageInstalled()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var projects = DTEUtil.GetProjects();

            foreach (IVsProject project in projects)
            {
                InitializeProject(project);
            }
        }
コード例 #22
0
        public static void SetupGenerated(IVsProject project, IceBuilderProjectType type)
        {
            if (type == IceBuilderProjectType.CppProjectType)
            {
                //
                // This will ensure that property reads don't use a cached project.
                //
                MSBuildUtils.LoadedProject(ProjectUtil.GetProjectFullPath(project), true, false);

                List <CppGeneratedFileSet> generated = GetCppGeneratedFiles(project);
                foreach (CppGeneratedFileSet fileset in generated)
                {
                    SetupGenerated(project, fileset.configuration, "Source Files", fileset.sources, generated.Count > 1);
                    SetupGenerated(project, fileset.configuration, "Header Files", fileset.headers, generated.Count > 1);
                }
                Package.Instance.FileTracker.Reap(GetProjectFullPath(project), GetCppGeneratedFiles(generated));
            }
            else // C# project
            {
                EnvDTE.Project p = DTEUtil.GetProject(project as IVsHierarchy);
                Dictionary <String, List <String> > generated = GetCSharpGeneratedFiles(project);
                foreach (KeyValuePair <String, List <String> > i in generated)
                {
                    foreach (String file in i.Value)
                    {
                        if (!Directory.Exists(Path.GetDirectoryName(file)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(file));
                        }

                        if (!File.Exists(file))
                        {
                            File.Create(file).Dispose();
                        }

                        EnvDTE.ProjectItem item = FindProjectItem(file);
                        if (item == null)
                        {
                            p.ProjectItems.AddFromFile(file);
                            try
                            {
                                //
                                // Remove the file otherwise it will be considered up to date.
                                //
                                File.Delete(file);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
                Package.Instance.FileTracker.Reap(GetProjectFullPath(project), generated);
            }
        }
コード例 #23
0
 public void InitializeProjects()
 {
     //
     // Postpone project initialization until the AddIn has been
     // removed.
     //
     if (!File.Exists(AddinPath))
     {
         OutputPane.Clear();
         InitializeProjects(DTEUtil.GetProjects(DTE.Solution));
     }
 }
コード例 #24
0
 public int OnAfterBackgroundSolutionLoadComplete()
 {
     try
     {
         Package.Instance.RunningDocumentTableEventHandler.BeginTrack();
         Package.Instance.InitializeProjects(DTEUtil.GetProjects());
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
     }
     return(0);
 }
コード例 #25
0
        private static bool UpdateImport(Microsoft.Build.Evaluation.Project project, string oldValue, string newValue)
        {
            ProjectImportElement import = project.Xml.Imports.FirstOrDefault(
                p => p.Project.Equals(oldValue, StringComparison.CurrentCultureIgnoreCase));

            if (import != null)
            {
                DTEUtil.EnsureFileIsCheckout(project.FullPath);
                import.Project   = newValue;
                import.Condition = string.Format("Exists('{0}')", newValue);
                return(true);
            }
            return(false);
        }
コード例 #26
0
        private static bool RemoveGlobalProperty(Microsoft.Build.Evaluation.Project project, string name)
        {
            ProjectPropertyGroupElement globals = project.Xml.PropertyGroups.FirstOrDefault(
                p => p.Label.Equals("Globals", StringComparison.CurrentCultureIgnoreCase));
            ProjectPropertyElement property = globals.Properties.FirstOrDefault(
                p => p.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));

            if (property != null)
            {
                DTEUtil.EnsureFileIsCheckout(project.FullPath);
                globals.RemoveChild(property);
                return(true);
            }
            return(false);
        }
コード例 #27
0
        public static List <String> GetGeneratedFiles(EnvDTE.Project project, String sliceFile)
        {
            List <String> generated = new List <String>();

            if (DTEUtil.IsCSharpProject(project))
            {
                generated.Add(ProjectUtil.GetCSharpGeneratedItemFullPath(project, sliceFile));
            }
            else
            {
                generated.Add(ProjectUtil.GetCppGeneratedSourceItemFullPath(project, sliceFile));
                generated.Add(ProjectUtil.GetCppGeneratedHeaderItemFullPath(project, sliceFile));
            }
            return(generated);
        }
コード例 #28
0
        private void PackageInstalled()
        {
            var projects = DTEUtil.GetProjects();

            foreach (IVsProject project in projects)
            {
                // Projects that are not being track has not been previous initialized
                // initialize will do nothing if zeroc.icebuilder.msbuild package is
                // not installed
                if (project.IsMSBuildIceBuilderInstalled())
                {
                    InitializeProject(project);
                }
            }
        }
コード例 #29
0
        private void PackageInstalled()
        {
            var projects = DTEUtil.GetProjects();

            foreach (IVsProject project in projects)
            {
                // Projects that are not being track has not been previous initialized
                // initialize will do nothing in zeroc.icebuilder.msbuild package is
                // not installed
                if (!FileTracker.Contains(ProjectUtil.GetProjectFullPath(project)))
                {
                    InitializeProject(project);
                }
            }
        }
コード例 #30
0
        private void BuildEvents_OnBuildBegin(EnvDTE.vsBuildScope scope, EnvDTE.vsBuildAction action)
        {
            try
            {
                if (action == EnvDTE.vsBuildAction.vsBuildActionBuild ||
                    action == EnvDTE.vsBuildAction.vsBuildActionRebuildAll)
                {
                    //
                    // Ensure this runs once for parallel builds.
                    //
                    if (Building)
                    {
                        return;
                    }
                    Building = true;
                }

                List <IVsProject> projects = new List <IVsProject>();
                if (scope.Equals(EnvDTE.vsBuildScope.vsBuildScopeSolution))
                {
                    projects = DTEUtil.GetProjects();
                }
                else
                {
                    IVsProject selected = DTEUtil.GetSelectedProject();
                    if (selected != null)
                    {
                        projects.Add(selected);
                        DTEUtil.GetSubProjects(selected, ref projects);
                    }
                }

                foreach (IVsProject project in projects)
                {
                    IceBuilderProjectType type = DTEUtil.IsIceBuilderEnabled(project);
                    if (type != IceBuilderProjectType.None)
                    {
                        ProjectUtil.SetupGenerated(project, type);
                    }
                }
            }
            catch (Exception ex)
            {
                Package.UnexpectedExceptionWarning(ex);
                throw;
            }
        }