Пример #1
0
        public EasyBuildManagerModel(EasyBuildManagerPackage package)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            this.package = package;
            EnvDTEWrapper.RegisterOnSolutionOpened(OnSolutionOpened);
            EnvDTEWrapper.RegisterOnSolutionClosed(OnSolutionClosed);
            RefreshSolutionCommand = new RelayCommand(action: () => Reload());
            CleanCommand           = new RelayCommand(CleanUnbuiltProjects);
            DgmlCommand            = new RelayCommand(GenerateDgml);
            RepairCommand          = new RelayCommand(RepairReferences);

            if (EnvDTEWrapper.IsSolutionOpened())
            {
                Reload();
            }
        }
Пример #2
0
 private void _Reload()
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     Solution = EnvDTEWrapper.GetCurrentSolution();
 }
Пример #3
0
 public void Reload()
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     Logger.ProfileFunction(function: () => _Reload(), name: $"Reload solution {EnvDTEWrapper.GetCurrentSolutionName()}");
 }
Пример #4
0
 public void ReloadProjects()
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     Projects = EnvDTEWrapper.GetProjects(this);
     UpdateCurrentConfig();
 }
        public static void RepairReferences(Solution solution)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var projectInfos = solution.Projects
                               .Where(p => p.NativeProject.Object is VCProject)
                               .Select(p =>
            {
                var vcproj       = p.NativeProject.Object as VCProject;
                var libImported  = EnvDTEWrapper.GetAdditionalDependencies(p);
                var libGenerated = EnvDTEWrapper.GetImportLibrary(p);

                return(new ProjectInfo
                {
                    Project = p,
                    VCProject = vcproj,
                    LibImported = new HashSet <string>(libImported.Split(';').Select(l => Path.GetFileName(l))),
                    LibGenerated = Path.GetFileName(libGenerated)
                });
            })
                               .ToArray();

            var projectInfoPerOutputLib = projectInfos
                                          .Where(p => p.LibGenerated.Length > 0)
                                          .ToDictionary(p => p.LibGenerated, p => p);

            Parallel.ForEach(projectInfos, p =>
            {
                foreach (var curLib in p.LibImported)
                {
                    if (!projectInfoPerOutputLib.TryGetValue(curLib, out ProjectInfo dependencyProjectInfo))
                    {
                        continue; // not lib coming from a project in the solution
                    }
                    if (p.Project.Dependencies.Contains(dependencyProjectInfo.Project))
                    {
                        continue; // project already added as reference
                    }
                    p.MissingDependencies.Add(dependencyProjectInfo);
                }
            });

            foreach (var p in projectInfos)
            {
                var refs = p.VCProject.VCReferences as VCReferences;

                foreach (var dependencyProjectInfo in p.MissingDependencies)
                {
                    try
                    {
                        var refAddedObj = refs.AddProjectReference((dependencyProjectInfo.Project).NativeProject);
                        if (refAddedObj is VCReference vcRefAdded)
                        {
                            vcRefAdded.CopyLocal  = false;
                            vcRefAdded.UseInBuild = false;
                        }
                        p.Project.Dependencies.Add(dependencyProjectInfo.Project);
                        dependencyProjectInfo.Project.Referecing.Add(p.Project);
                    }
                    catch (Exception)
                    { }
                }

                //foreach (var curRefProj in p.Project.Dependencies)
                //{
                //    if (!projectInfoPerProject.TryGetValue(curRefProj, out ProjectInfo curRefProjInfo))
                //        continue;
                //
                //    if (!p.LibImported.Contains(curRefProjInfo.LibGenerated))
                //    {
                //        try
                //        {
                //            refs.RemoveReference((curRefProjInfo.Project as VisualStudioProject).NativeProject.re);
                //        }
                //        catch (Exception)
                //        { }
                //        continue;
                //    }
                //}
            }
            ;
        }