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);
 }
 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);
 }
 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);
 }
Exemple #4
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.IsIceBuilderNuGetInstalled(project);
                    if (type != IceBuilderProjectType.None)
                    {
                        ProjectUtil.SetupGenerated(project, type);
                    }
                }
            }
            catch (Exception ex)
            {
                UnexpectedExceptionWarning(ex);
            }
        }
Exemple #5
0
 public void BuildNextProject()
 {
     if (_buildProjects.Count == 0)
     {
         BuildContext(false);
     }
     else if (!Building && BuildingProject == null)
     {
         IVsProject p = _buildProjects.ElementAt(0);
         ProjectUtil.SaveProject(p);
         ProjectUtil.SetupGenerated(p, DTEUtil.IsIceBuilderNuGetInstalled(p));
         if (BuildProject(p))
         {
             _buildProjects.Remove(p);
         }
     }
 }
Exemple #6
0
 public int OnBeforeCloseProject(IVsHierarchy pHierarchy, int fRemoved)
 {
     try
     {
         IVsProject project = pHierarchy as IVsProject;
         if (project != null)
         {
             if (DTEUtil.IsIceBuilderNuGetInstalled(project) != IceBuilderProjectType.None)
             {
                 Package.Instance.FileTracker.Remove(ProjectUtil.GetProjectFullPath(project));
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
     }
     return(0);
 }
 public int OnAfterSave(uint docCookie)
 {
     try
     {
         if (Package.Instance.AutoBuilding)
         {
             IVsProject project = null;
             uint       item    = 0;
             string     path    = null;
             GetDocumentInfo(docCookie, ref project, ref item, ref path);
             if (DTEUtil.IsIceBuilderNuGetInstalled(project) != IceBuilderProjectType.None &&
                 ProjectUtil.IsSliceFileName(path))
             {
                 Package.Instance.QueueProjectsForBuilding(new List <IVsProject>(new IVsProject[] { project }));
             }
         }
     }
     catch (Exception ex)
     {
         Package.UnexpectedExceptionWarning(ex);
     }
     return(0);
 }
Exemple #8
0
        public void InitializeProject(IVsProject project)
        {
            IceBuilderProjectType projectType = DTEUtil.IsIceBuilderNuGetInstalled(project);

            if (projectType != IceBuilderProjectType.None)
            {
                var dteproject = project.GetDTEProject();
                if (projectType == IceBuilderProjectType.CppProjectType)
                {
                    VCUtil.SetupSliceFilter(dteproject);
                }
                else
                {
                    if (project is IVsAggregatableProject)
                    {
                        if (MSBuildUtils.AddProjectFlavorIfNotExists(project.GetMSBuildProject(true), IceBuilderNewFlavor))
                        {
                            dteproject.Save();
                        }
                    }
                }
                FileTracker.Add(project, projectType);
            }
        }